org.apache.activemq.artemis.core.transaction.impl.XidImpl.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.activemq.artemis.core.transaction.impl.XidImpl.<init>()方法的一些代码示例,展示了XidImpl.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XidImpl.<init>()方法的具体详情如下:
包路径:org.apache.activemq.artemis.core.transaction.impl.XidImpl
类名称:XidImpl
方法名:<init>

XidImpl.<init>介绍

[英]Copy constructor
[中]复制构造函数

代码示例

代码示例来源:origin: wildfly/wildfly

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: apache/activemq-artemis

protected XidImpl newXID(byte[] bytes) {
 return new XidImpl("amqp".getBytes(), 1, bytes);
}

代码示例来源:origin: org.apache.activemq/artemis-amqp-protocol

protected XidImpl newXID(byte[] bytes) {
 return new XidImpl("amqp".getBytes(), 1, bytes);
}

代码示例来源:origin: apache/activemq-artemis

public static XidImpl toXID(XATransactionId xaXid) {
   return new XidImpl(xaXid.getBranchQualifier(), xaXid.getFormatId(), xaXid.getGlobalTransactionId());
  }
}

代码示例来源:origin: apache/activemq-artemis

XADummyEndpoint(CountDownLatch latch) {
  super(latch);
  xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
}

代码示例来源:origin: apache/activemq-artemis

protected XidImpl newXID() {
 return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
}

代码示例来源:origin: apache/activemq-artemis

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: apache/activemq-artemis

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: apache/activemq-artemis

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: org.apache.activemq/artemis-core-client

public static Xid decodeXid(final ActiveMQBuffer in) {
 int formatID = in.readInt();
 byte[] bq = new byte[in.readInt()];
 in.readBytes(bq);
 byte[] gtxid = new byte[in.readInt()];
 in.readBytes(gtxid);
 Xid xid = new XidImpl(bq, formatID, gtxid);
 return xid;
}

代码示例来源:origin: apache/activemq-artemis

/**
* In case a timeout happens the server's object may still have the previous XID.
* for that reason a new start call is supposed to clean it up with a log.warn
* but it should still succeed
*
* @throws Exception
*/
@Test
public void testChangeXID() throws Exception {
 Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
 Xid xid2 = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
 clientSession.start(xid, XAResource.TMNOFLAGS);
 clientSession.start(xid2, XAResource.TMNOFLAGS);
}

代码示例来源:origin: apache/activemq-artemis

public static Xid randomXid() {
   return new XidImpl(randomBytes(), randomInt(), randomBytes());
  }
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 120000)
public void testXAMessagesNotSentSoNoRollbackOnCommit() throws Exception {
 createSessionFactory();
 ClientSession session = createSession(sf, true, false, false);
 Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
 session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
 ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
 session.start(xid, XAResource.TMNOFLAGS);
 sendMessagesSomeDurable(session, producer);
 session.end(xid, XAResource.TMSUCCESS);
 session.prepare(xid);
 session.commit(xid, false);
 crash(session);
 ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
 session.start();
 Xid xid2 = new XidImpl("tfytftyf".getBytes(), 54654, "iohiuohiuhgiu".getBytes());
 session.start(xid2, XAResource.TMNOFLAGS);
 receiveDurableMessages(consumer);
 session.end(xid2, XAResource.TMSUCCESS);
 session.prepare(xid2);
 session.commit(xid2, false);
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 120000)
public void testXAMessagesConsumedSoRollbackOnEnd() throws Exception {
 createSessionFactory();
 ClientSession session1 = createSessionAndQueue();
 ClientProducer producer = session1.createProducer(FailoverTestBase.ADDRESS);
 sendMessagesSomeDurable(session1, producer);
 session1.commit();
 ClientSession session2 = createSession(sf, true, false, false);
 ClientConsumer consumer = session2.createConsumer(FailoverTestBase.ADDRESS);
 session2.start();
 Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
 session2.start(xid, XAResource.TMNOFLAGS);
 receiveMessages(consumer);
 crash(session2);
 try {
   session2.end(xid, XAResource.TMSUCCESS);
   Assert.fail("Should throw exception");
 } catch (XAException e) {
   Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode);
 }
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 120000)
public void testXAMessagesConsumedSoRollbackOnPrepare() throws Exception {
 createSessionFactory();
 ClientSession session1 = createSessionAndQueue();
 ClientProducer producer = session1.createProducer(FailoverTestBase.ADDRESS);
 sendMessagesSomeDurable(session1, producer);
 session1.commit();
 ClientSession session2 = createSession(sf, true, false, false);
 ClientConsumer consumer = session2.createConsumer(FailoverTestBase.ADDRESS);
 session2.start();
 Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
 session2.start(xid, XAResource.TMNOFLAGS);
 receiveMessages(consumer);
 session2.end(xid, XAResource.TMSUCCESS);
 crash(session2);
 try {
   session2.prepare(xid);
   Assert.fail("Should throw exception");
 } catch (XAException e) {
   Assert.assertEquals(XAException.XAER_RMFAIL, e.errorCode);
 }
}

代码示例来源:origin: apache/activemq-artemis

@Test
public void testXAResourceRolledBackSuspendedNotRemoved() throws Exception {
 Queue queue = null;
 Xid xid = newXID();
 try (XAConnection xaconnection = xaFactory.createXAConnection()) {
   XASession session = xaconnection.createXASession();
   queue = session.createQueue(queueName);
   session.getXAResource().start(xid, XAResource.TMNOFLAGS);
   session.getXAResource().end(xid, XAResource.TMSUSPEND);
   XidImpl xid1 = new XidImpl(xid);
   Transaction transaction = server.getResourceManager().getTransaction(xid1);
   //directly suspend the tx
   transaction.suspend();
   session.getXAResource().rollback(xid);
 } catch (XAException ex) {
  //ignore
 } finally {
   XidImpl xid1 = new XidImpl(xid);
   Transaction transaction = server.getResourceManager().getTransaction(xid1);
   assertNotNull(transaction);
 }
}

代码示例来源:origin: apache/activemq-artemis

@Test
public void testXAResourceCommittedRemoved() throws Exception {
 Queue queue = null;
 Xid xid = newXID();
 try (XAConnection xaconnection = xaFactory.createXAConnection()) {
   XASession session = xaconnection.createXASession();
   queue = session.createQueue(queueName);
   session.getXAResource().start(xid, XAResource.TMNOFLAGS);
   MessageProducer producer = session.createProducer(queue);
   producer.send(session.createTextMessage("xa message"));
   session.getXAResource().end(xid, XAResource.TMSUCCESS);
   session.getXAResource().commit(xid, true);
 }
 XidImpl xid1 = new XidImpl(xid);
 Transaction transaction = server.getResourceManager().getTransaction(xid1);
 assertNull(transaction);
}

代码示例来源:origin: apache/activemq-artemis

@Test
public void testXAResourceRolledBackRemoved() throws Exception {
 Queue queue = null;
 Xid xid = newXID();
 try (XAConnection xaconnection = xaFactory.createXAConnection()) {
   XASession session = xaconnection.createXASession();
   queue = session.createQueue(queueName);
   session.getXAResource().start(xid, XAResource.TMNOFLAGS);
   MessageProducer producer = session.createProducer(queue);
   producer.send(session.createTextMessage("xa message"));
   session.getXAResource().end(xid, XAResource.TMSUCCESS);
   session.getXAResource().rollback(xid);
 }
 XidImpl xid1 = new XidImpl(xid);
 Transaction transaction = server.getResourceManager().getTransaction(xid1);
 assertNull(transaction);
}

相关文章