JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();
MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
   public void testMultipleSessionsOneTxRollbackAcknowledge() throws Exception   {      if (ServerManagement.isRemote()) return;            XAConnection conn = null;      Connection conn2 = null;      try      {         //First send 2 messages         conn2 = cf.createConnection();         Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer prod  = sessProducer.createProducer(queue);         Message m = sessProducer.createTextMessage("jellyfish1");         prod.send(m);         m = sessProducer.createTextMessage("jellyfish2");         prod.send(m);         m = sessProducer.createTextMessage("jellyfish3");         prod.send(m);         m = sessProducer.createTextMessage("jellyfish4");         prod.send(m);                           conn = cf.createXAConnection();         conn.start();                     tm.begin();                  //Create 2 sessions and enlist them         XASession sess1 = conn.createXASession();         JBossXAResource res1 = (JBossXAResource)sess1.getXAResource();         XASession sess2 = conn.createXASession();         JBossXAResource res2 = (JBossXAResource)sess2.getXAResource();         res1.setPreventJoining(true);         res2.setPreventJoining(true);                  Transaction tx = tm.getTransaction();         tx.enlistResource(res1);         tx.enlistResource(res2);                  //Receive the messages, two on each consumer         MessageConsumer cons1 = sess1.createConsumer(queue);         TextMessage r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish1", r1.getText());                  r1 = (TextMessage)cons1.receive(1000);                  assertNotNull(r1);         assertEquals("jellyfish2", r1.getText());                           cons1.close();                  MessageConsumer cons2 = sess2.createConsumer(queue);         TextMessage r2 = (TextMessage)cons2.receive(1000);                  assertNotNull(r2);         assertEquals("jellyfish3", r2.getText());                  r2 = (TextMessage)cons2.receive(1000);                  assertNotNull(r2);         assertEquals("jellyfish4", r2.getText());                  //rollback                                            tx.rollback();                  Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageConsumer cons = sess.createConsumer(queue);         conn2.start();                  //NOTE         //The order here is actually probably dependent on the transaction manager implementation         //In this case, rollback will be called on each session, but whether it is called first on res1         //or res2 determines the order the messages are put back in the queue         //This test assumes it is called in order res1, res2                  TextMessage r3 = (TextMessage)cons.receive(1000);                  assertNotNull(r3);         assertEquals("jellyfish3", r3.getText());                  r3 = (TextMessage)cons.receive(1000);                  assertNotNull(r3);         assertEquals("jellyfish4", r3.getText());         //log.info(r3.getText());                  TextMessage r4 = (TextMessage)cons.receive(1000);                  assertNotNull(r4);         assertEquals("jellyfish1", r4.getText());         //log.info(r4.getText());                  r4 = (TextMessage)cons.receive(1000);                  assertNotNull(r4);         assertEquals("jellyfish2", r4.getText());               }      finally      {         if (conn != null)         {            conn.close();         }         if (conn2 != null)         {            conn2.close();         }      }         }