// Do some work in the new transaction
publisher.publish(message);
// Commit the first transaction and end the branch
resource.end(xid1, XAResource.TMSUCCESS);
resource.commit(xid1, true);
// Do some more work in the new transaction
publisher.publish(message);
// Commit the second transaction and end the branch