Assert.assertEquals(m.getBodyBuffer().readString(), "m8");
}
public void testBasicReceiveWithCommit(final boolean stopServer) throws Exception
{
Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
ClientMessage m1 = createTextMessage("m1");
ClientMessage m2 = createTextMessage("m2");
ClientMessage m3 = createTextMessage("m3");
ClientMessage m4 = createTextMessage("m4");
ClientSession clientSession2 = sessionFactory.createSession(false, true, true);
ClientProducer clientProducer2 = clientSession2.createProducer(atestq);
clientProducer2.send(m1);
clientProducer2.send(m2);
clientProducer2.send(m3);
clientProducer2.send(m4);
clientSession2.close();
clientSession.start(xid, XAResource.TMNOFLAGS);
clientSession.start();
ClientMessage m = clientConsumer.receive(1000);
m.acknowledge();
Assert.assertNotNull(m);
Assert.assertEquals(m.getBodyBuffer().readString(), "m1");
m = clientConsumer.receive(1000);
Assert.assertNotNull(m);
m.acknowledge();
Assert.assertEquals(m.getBodyBuffer().readString(), "m2");
m = clientConsumer.receive(1000);
m.acknowledge();
Assert.assertNotNull(m);
Assert.assertEquals(m.getBodyBuffer().readString(), "m3");
m = clientConsumer.receive(1000);
m.acknowledge();
Assert.assertNotNull(m);
Assert.assertEquals(m.getBodyBuffer().readString(), "m4");
clientSession.end(xid, XAResource.TMSUCCESS);
Assert.assertEquals("Expected XA_OK", XAResource.XA_OK, clientSession.prepare(xid));
if (stopServer)
{
stopAndRestartServer();
}
else
{
recreateClients();
}
Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
Assert.assertEquals(xids.length, 1);
Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId());
UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier());
UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId());
xids = clientSession.recover(XAResource.TMENDRSCAN);
Assert.assertEquals(xids.length, 0);
clientSession.commit(xid, false);
clientSession.start();
m = clientConsumer.receiveImmediate();