try
{
conn = cf.createXAConnection();
Xid xid1, xid2;
{
XASession sess = conn.createXASession();
XAResource res = sess.getXAResource();
MessageProducer prod = sess.createProducer(queue);
xid1 = new MessagingXid("blah1".getBytes(), 42, "blahblah1".getBytes());
TextMessage tm = sess.createTextMessage("message1");
res.start(xid1, XAResource.TMNOFLAGS);
prod.send(tm);
res.end(xid1, XAResource.TMSUCCESS);
res.prepare(xid1);
}
{
XASession sess = conn.createXASession();
XAResource res = sess.getXAResource();
MessageProducer prod = sess.createProducer(queue);
xid2 = new MessagingXid("blah2".getBytes(), 42, "blahblah2".getBytes());
TextMessage tm = sess.createTextMessage("message1");
res.start(xid2, XAResource.TMNOFLAGS);
prod.send(tm);
res.end(xid2, XAResource.TMSUCCESS);
res.prepare(xid2);
}
List txList = (List)ServerManagement.invoke(ServerManagement.getServerPeerObjectName(),
"retrievePreparedTransactions", null, null);
assertNotNull(txList);
assertEquals(2, txList.size());
Xid rxid1 = (Xid)txList.get(0);
Xid rxid2 = (Xid)txList.get(1);
boolean ok = (xid1.equals(rxid1) && xid2.equals(rxid2)) ||
(xid2.equals(rxid1) && xid1.equals(rxid2));