conn2.start();
XASession sess2 = conn2.createXASession();
XAResource res = sess2.getXAResource();
Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
res.start(xid1, XAResource.TMNOFLAGS);
MessageProducer prod3 = sess2.createProducer(queueA);
TextMessage tm9 = sess2.createTextMessage("tm9");
TextMessage tm10 = sess2.createTextMessage("tm10");
TextMessage tm11 = sess2.createTextMessage("tm11");
TextMessage tm12 = sess2.createTextMessage("tm12");
prod3.send(tm9);
prod3.send(tm10);
prod3.send(tm11);
prod3.send(tm12);
MessageProducer prod4 = sess2.createProducer(queueB);
TextMessage tm13 = sess2.createTextMessage("tm13");
TextMessage tm14 = sess2.createTextMessage("tm14");
TextMessage tm15 = sess2.createTextMessage("tm15");
TextMessage tm16 = sess2.createTextMessage("tm16");
prod4.send(tm13);
prod4.send(tm14);
prod4.send(tm15);
prod4.send(tm16);
MessageConsumer cons1 = sess2.createConsumer(queueA);
TextMessage rm1 = (TextMessage)cons1.receive(1000);
assertNotNull(rm1);
assertEquals(tm1.getText(), rm1.getText());
TextMessage rm2 = (TextMessage)cons1.receive(1000);
assertNotNull(rm2);
assertEquals(tm2.getText(), rm2.getText());
TextMessage rm3 = (TextMessage)cons1.receive(1000);
assertNotNull(rm3);
assertEquals(tm3.getText(), rm3.getText());
TextMessage rm4 = (TextMessage)cons1.receive(1000);
assertNotNull(rm4);
assertEquals(tm4.getText(), rm4.getText());
Message m = cons1.receive(1000);
assertNull(m);
MessageConsumer cons2 = sess2.createConsumer(queueB);
TextMessage rm5 = (TextMessage)cons2.receive(1000);
assertNotNull(rm5);
assertEquals(tm5.getText(), rm5.getText());
TextMessage rm6 = (TextMessage)cons2.receive(1000);
assertNotNull(rm6);
assertEquals(tm6.getText(), rm6.getText());
TextMessage rm7 = (TextMessage)cons2.receive(1000);
assertNotNull(rm7);
assertEquals(tm7.getText(), rm7.getText());
TextMessage rm8 = (TextMessage)cons2.receive(1000);
assertNotNull(rm8);
assertEquals(tm8.getText(), rm8.getText());
m = cons2.receive(1000);
assertNull(m);
res.end(xid1, XAResource.TMSUCCESS);
//prepare it
res.prepare(xid1);
conn1 = null;
conn2 = null;
// Now "crash" the server
ServerManagement.stopServerPeer();
ServerManagement.startServerPeer();
ServerManagement.deployQueue("QA");
ServerManagement.deployQueue("QB");
conn3 = cf.createXAConnection();
XASession sess3 = conn3.createXASession();
XAResource res3 = sess3.getXAResource();
Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
assertEquals(1, xids.length);
Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
assertEquals(0, xids2.length);
assertEquals(xid1, xids[0]);
log.trace("Committing the tx");
//Commit
res3.commit(xids[0], false);
log.trace("committed the tx");
conn1 = cf.createConnection();