session.createTextMessage("First Message"),
session.createTextMessage("Second Message")
};
XidStub xid1 = new XidStub(new byte[]{1, 2, 3, 4, 5});
resource.start(xid1, XAResource.TMNOFLAGS);
producer.send(outbound[0]);
resource.end(xid1, XAResource.TMSUCCESS);
resource.commit(xid1, true);
XidStub xid2 = new XidStub(new byte[]{2, 2, 3, 4, 5});
resource.start(xid2, XAResource.TMNOFLAGS);
producer.send(session.createTextMessage("I'm going to get rolled back."));
resource.end(xid2, XAResource.TMSUCCESS);
resource.rollback(xid2);
XidStub xid3 = new XidStub(new byte[]{3, 2, 3, 4, 5});
resource.start(xid3, XAResource.TMNOFLAGS);
producer.send(outbound[1]);
resource.end(xid3, XAResource.TMSUCCESS);
if (resource.prepare(xid3) == XAResource.XA_OK) {
resource.commit(xid3, false);
}
ArrayList messages = new ArrayList();
XidStub xid4 = new XidStub(new byte[]{4, 2, 3, 4, 5});
resource.start(xid4, XAResource.TMNOFLAGS);
messages.add(consumer.receive(1000));
messages.add(consumer.receive(1000));
resource.end(xid4, XAResource.TMSUCCESS);
resource.commit(xid4, true);