Package org.jboss.jms.tx

Examples of org.jboss.jms.tx.MessagingXid


         testPacket(resp, PacketSupport.RESP_CONNECTION_GETCLIENTID);                          
      }
     
      public void testConnectionGetClientPreparedTransactionsResponse() throws Exception
      {
         MessagingXid xid = new MessagingXid("okokko".getBytes(), 23, "okjokokdd".getBytes());        
                 
         ResponseSupport resp =
            new ConnectionGetPreparedTransactionsResponse(new MessagingXid[] { xid });
                
         testPacket(resp, PacketSupport.RESP_CONNECTION_GETPREPAREDTRANSACTIONS);                          
View Full Code Here


     
      try
      {     
         int iterations = numMessages / commitSize;
        
         MessagingXid xid = null;
        
         xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().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)
               {
                  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)
                  {
                     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)
                  {
                     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 MessagingXid("bq1".getBytes(), 1, new GUID().toString().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)
               {
                  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)
                  {
                     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)
                  {
                     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 MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
                  xaResource.start(xid, XAResource.TMNOFLAGS);
               }
               processingDone();
            }           
         }
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);

         xconn1.start();

         // Consume the message

         TextMessage rm1 = (TextMessage)cons.receive(1000);

         assertNotNull(rm1);

         assertEquals(tm1.getText(), rm1.getText());

         res1.end(xid1, XAResource.TMSUCCESS);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);

         // prepare the tx
         res1.prepare(xid1);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);
        
         res1.rollback(xid1);

         //start another Tx, and rollback again.
         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "eemeli".getBytes());
         res1.start(xid2, XAResource.TMNOFLAGS);

         rm1 = (TextMessage)cons.receive(1000);
         assertNotNull(rm1);
         assertEquals(tm1.getText(), rm1.getText());
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);

         xconn1.start();

         // Consume the message

         TextMessage rm1 = (TextMessage)cons.receive(1000);

         assertNotNull(rm1);

         assertEquals(tm1.getText(), rm1.getText());

         res1.end(xid1, XAResource.TMSUCCESS);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);

         //roll back directly
         res1.rollback(xid1);

         //start another Tx, and rollback again.
         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "eemeli".getBytes());
         res1.start(xid2, XAResource.TMNOFLAGS);

         rm1 = (TextMessage)cons.receive(1000);
         assertNotNull(rm1);
         assertEquals(tm1.getText(), rm1.getText());
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);

         xconn1.start();

         // Consume the message

         TextMessage rm1 = (TextMessage)cons.receive(1000);

         assertNotNull(rm1);

         assertEquals(tm1.getText(), rm1.getText());

         res1.end(xid1, XAResource.TMSUCCESS);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);

         //roll back directly
         res1.rollback(xid1);

         //start another Tx, and rollback again.
         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "eemeli".getBytes());
         res1.start(xid2, XAResource.TMNOFLAGS);

         rm1 = (TextMessage)cons.receive(1000);
         assertNotNull(rm1);
         assertEquals(tm1.getText(), rm1.getText());
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);

         xconn1.start();

         // Consume the message

         TextMessage rm1 = (TextMessage)cons.receive(1000);

         assertNotNull(rm1);

         assertEquals(tm1.getText(), rm1.getText());

         res1.end(xid1, XAResource.TMSUCCESS);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);

         // prepare the tx
         res1.prepare(xid1);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);
        
         res1.rollback(xid1);

         //start another Tx, and rollback again.
         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "eemeli".getBytes());
         res1.start(xid2, XAResource.TMNOFLAGS);

         rm1 = (TextMessage)cons.receive(1000);
         assertNotNull(rm1);
         assertEquals(tm1.getText(), rm1.getText());
View Full Code Here

         XASession xsess1 = xconn1.createXASession();

         XAResource res1 = xsess1.getXAResource();

         // Pretend to be a transaction manager by interacting through the XAResources
         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());

         res1.start(xid1, XAResource.TMNOFLAGS);

         MessageConsumer cons = xsess1.createConsumer(queue1);

         xconn1.start();

         // Consume the message

         TextMessage rm1 = (TextMessage)cons.receive(1000);

         assertNotNull(rm1);

         assertEquals(tm1.getText(), rm1.getText());

         res1.end(xid1, XAResource.TMSUCCESS);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);

         // prepare the tx
         res1.prepare(xid1);

         // next message should not be received.
         rm1 = (TextMessage)cons.receive(2000);
         assertNull(rm1);
        
         res1.rollback(xid1);
        
         xsess1.getSession().close();

         XASession xsess2 = xconn1.createXASession();

         XAResource res2 = xsess2.getXAResource();
        
         MessageConsumer cons2 = xsess2.createConsumer(queue1);

         //start another Tx, commit it.
         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "eemeli".getBytes());
         res2.start(xid2, XAResource.TMNOFLAGS);

         rm1 = (TextMessage)cons2.receive(1000);
         assertNotNull(rm1);
         assertEquals(tm1.getText(), rm1.getText());
View Full Code Here

               XAResource res1 = xsess1.getXAResource();
              
               String bqStr = "bq" + i;

               // Pretend to be a transaction manager by interacting through the XAResources
               Xid xid1 = new MessagingXid(bqStr.getBytes(), 42, "eemeli".getBytes());

               res1.start(xid1, XAResource.TMNOFLAGS);

               xcons1 = xsess1.createConsumer(queue1);
View Full Code Here

TOP

Related Classes of org.jboss.jms.tx.MessagingXid

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.