Package org.hornetq.core.transaction.impl

Examples of org.hornetq.core.transaction.impl.XidImpl


         XAResource res1 = sess1.getXAResource();

         XAResource res2 = sess2.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new XidImpl("bq1".getBytes(), 123, "gbtxid1".getBytes());
         Xid xid2 = new XidImpl("bq2".getBytes(), 124, "gbtxid2".getBytes());

         // Send a message in each tx

         res1.start(xid1, XAResource.TMNOFLAGS);
View Full Code Here


      try
      {
         for (int outerCount = 0; outerCount < iterations; outerCount++)
         {
            XidImpl xid = null;
            if (commitSize > 0)
            {
               xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
               xaResource.start(xid, XAResource.TMNOFLAGS);
            }
            for (int innerCount = 0; innerCount < commitSize; innerCount++)
            {
               Message m = sess.createMessage();
               m.setStringProperty("PROD_NAME", prodName);
               m.setIntProperty("MSG_NUMBER", outerCount * commitSize + innerCount);
               prod.send(m);
            }
            if (commitSize > 0)
            {
               xaResource.end(xid, XAResource.TMSUCCESS);
               xaResource.prepare(xid);
               xaResource.commit(xid, false);
            }
            if (rollbackSize > 0)
            {
               xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
               xaResource.start(xid, XAResource.TMNOFLAGS);
            }
            for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
            {
               Message m = sess.createMessage();
View Full Code Here

      try
      {
         int iterations = numMessages / commitSize;

         XidImpl xid = null;

         xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
         xaResource.start(xid, XAResource.TMNOFLAGS);

         for (int outerCount = 0; outerCount < iterations; outerCount++)
         {

            for (int innerCount = 0; innerCount < commitSize; innerCount++)
            {
               Message m = getMessage();

               if (m == null)
               {
                  Transactional2PCReceiver.log.error("Message is null");
                  setFailed(true);
                  return;
               }
               String prodName = m.getStringProperty("PROD_NAME");
               Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));

               Count count = (Count)counts.get(prodName);
               if (count == null)
               {
                  // First time
                  if (msgCount.intValue() != 0)
                  {
                     Transactional2PCReceiver.log.error("First message from " + prodName +
                                                        " is not 0, it is " +
                                                        msgCount);
                     setFailed(true);
                     return;
                  }
                  else
                  {
                     count = new Count();
                     counts.put(prodName, count);
                  }
               }
               else
               {
                  if (count.lastCommitted != msgCount.intValue() - 1)
                  {
                     Transactional2PCReceiver.log.error("Message out of sequence for " + prodName +
                                                        ", expected " +
                                                        (count.lastCommitted + 1) +
                                                        ", actual " +
                                                        msgCount);
                     setFailed(true);
                     return;
                  }
               }
               count.lastCommitted = msgCount.intValue();

               count.lastReceived = msgCount.intValue();

               if (innerCount == commitSize - 1)
               {
                  xaResource.end(xid, XAResource.TMSUCCESS);
                  xaResource.prepare(xid);
                  xaResource.commit(xid, false);

                  // Starting new tx
                  xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
                  xaResource.start(xid, XAResource.TMNOFLAGS);

               }

               processingDone();
            }

            if (outerCount == iterations - 1)
            {
               break;
            }

            for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
            {
               Message m = getMessage();

               if (m == null)
               {
                  Transactional2PCReceiver.log.error("Message is null (rollback)");
                  setFailed(true);
                  return;
               }
               String prodName = m.getStringProperty("PROD_NAME");
               Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));

               Count count = (Count)counts.get(prodName);
               if (count == null)
               {
                  // First time
                  if (msgCount.intValue() != 0)
                  {
                     Transactional2PCReceiver.log.error("First message from " + prodName +
                                                        " is not 0, it is " +
                                                        msgCount);
                     setFailed(true);
                     return;
                  }
                  else
                  {
                     count = new Count();
                     count.lastCommitted = -1;
                     counts.put(prodName, count);
                  }
               }
               else
               {
                  if (count.lastReceived != msgCount.intValue() - 1)
                  {
                     Transactional2PCReceiver.log.error("Message out of sequence");
                     setFailed(true);
                     return;
                  }
               }
               count.lastReceived = msgCount.intValue();

               if (innerCount == rollbackSize - 1)
               {
                  xaResource.end(xid, XAResource.TMSUCCESS);
                  xaResource.prepare(xid);
                  xaResource.rollback(xid);

                  xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
                  xaResource.start(xid, XAResource.TMNOFLAGS);
               }
               processingDone();
            }
         }
View Full Code Here

      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;
   }
View Full Code Here

         this.session = session;
      }

      public void onMessage(final ClientMessage message)
      {
         Xid xid = new XidImpl(UUIDGenerator.getInstance().generateStringUUID().getBytes(),
                               1,
                               UUIDGenerator.getInstance().generateStringUUID().getBytes());
         try
         {
            session.start(xid, XAResource.TMNOFLAGS);
View Full Code Here

   {
      SimpleString recQueue = new SimpleString("BasicXaTestqRec");
      SimpleString sendQueue = new SimpleString("BasicXaTestqSend");

      byte[] globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes();
      Xid xid = new XidImpl("xa1".getBytes(), 1, globalTransactionId);
      Xid xid2 = new XidImpl("xa2".getBytes(), 1, globalTransactionId);
      ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
      ClientSessionFactory csf = locator.createSessionFactory();
      ClientSession clientSession = csf.createSession(true, false, false);
      clientSession.createQueue(recQueue, recQueue, null, true);
      clientSession.createQueue(sendQueue, sendQueue, null, true);
View Full Code Here

      ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 2);

      ClientSession session = createSession(sf, true, false, false);

      Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());

      session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);

      ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
View Full Code Here

      ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 2);

      ClientSession session = createSession(sf, true, false, false);

      Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());

      session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);

      ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
View Full Code Here

      ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 2);

      ClientSession session = createSession(sf, true, false, false);

      Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());

      session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);

      ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
View Full Code Here

      ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 2);

      ClientSession session = createSession(sf, true, false, false);

      Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());

      session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);

      ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);

      final int numMessages = 100;

      session.start(xid, XAResource.TMNOFLAGS);

      for (int i = 0; i < numMessages; i++)
      {
         ClientMessage message = session.createMessage(i % 2 == 0);

         setBody(i, message);

         message.putIntProperty("counter", i);

         producer.send(message);
      }

      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);

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

TOP

Related Classes of org.hornetq.core.transaction.impl.XidImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.