final Xid xid = XIDGenerator.createXID(this.formatIdIdGenerator.incrementAndGet(), uniqueQualifier);
// ��������ʱΪ2��
xares.setTransactionTimeout(2);
xares.start(xid, XAResource.TMNOFLAGS);
final SendResult result = this.producer.sendMessage(msg);
if (!result.isSuccess()) {
xares.end(xid, XAResource.TMFAIL);
xares.rollback(xid);
throw new RuntimeException("Send message failed:" + result.getErrorMessage());
}
// �ȴ�3��
xares.end(xid, XAResource.TMSUCCESS);
Thread.sleep(3000);
// prepare����ʧ��
try {
xares.prepare(xid);
fail();
}
catch (final XAException e) {
e.printStackTrace();
}
this.createConsumer("consumer-test");
// this.consumer.subscribe(this.topic, 1024,
// null).completeSubscribe();
System.out.println(result.getPartition());
final MessageIterator it = this.consumer.get(this.topic, result.getPartition(), 0, 1024);
assertNull(it);
}
finally {
this.producer.shutdown();
this.consumer.shutdown();