conn2.start();
XASession sess2 = conn2.createXASession();
XAResource res = sess2.getXAResource();
Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
res.start(xid1, XAResource.TMNOFLAGS);
//Now send four more messages in a global tx
MessageProducer prod2 = sess2.createProducer(topicTX);
TextMessage tm5 = sess2.createTextMessage("tm5");
TextMessage tm6 = sess2.createTextMessage("tm6");
TextMessage tm7 = sess2.createTextMessage("tm7");
TextMessage tm8 = sess2.createTextMessage("tm8");
prod2.send(tm5);
prod2.send(tm6);
prod2.send(tm7);
prod2.send(tm8);
//And consume the first four from each in the tx
sub1 = sess2.createDurableSubscriber((Topic)topicTX, "sub1");
sub2 = sess2.createDurableSubscriber((Topic)topicTX, "sub2");
TextMessage rm1 = (TextMessage)sub1.receive(1000);
assertNotNull(rm1);
assertEquals(tm1.getText(), rm1.getText());
TextMessage rm2 = (TextMessage)sub1.receive(1000);
assertNotNull(rm2);
assertEquals(tm2.getText(), rm2.getText());
TextMessage rm3 = (TextMessage)sub1.receive(1000);
assertNotNull(rm3);
assertEquals(tm3.getText(), rm3.getText());
TextMessage rm4 = (TextMessage)sub1.receive(1000);
assertNotNull(rm4);
assertEquals(tm4.getText(), rm4.getText());
Message m = sub1.receive(1000);
assertNull(m);
rm1 = (TextMessage)sub2.receive(1000);
assertNotNull(rm1);
assertEquals(tm1.getText(), rm1.getText());
rm2 = (TextMessage)sub2.receive(1000);
assertNotNull(rm2);
assertEquals(tm2.getText(), rm2.getText());
rm3 = (TextMessage)sub2.receive(1000);
assertNotNull(rm3);
assertEquals(tm3.getText(), rm3.getText());
rm4 = (TextMessage)sub2.receive(1000);
assertNotNull(rm4);
assertEquals(tm4.getText(), rm4.getText());
m = sub2.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.deployTopic("TXTOPIC");
conn3 = cf.createXAConnection();
XASession sess3 = conn3.createXASession();
XAResource res3 = sess3.getXAResource();
//recover
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();