@Override
public void send(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception {
if (messageSend.isInTransaction() && messageSend.getProperty("NUM") != null) {
final Integer num = (Integer) messageSend.getProperty("NUM");
if (true) {
TransactionBroker transactionBroker = (TransactionBroker)broker.getBroker().getAdaptor(TransactionBroker.class);
transactionBroker.getTransaction(producerExchange.getConnectionContext(), messageSend.getTransactionId(), false).addSynchronization(
new Synchronization() {
public void afterCommit() throws Exception {
LOG.error("AfterCommit, NUM:" + num + ", " + messageSend.getMessageId() + ", tx: " + messageSend.getTransactionId());
if (num == 5) {
// we want to add to cursor after usage is exhausted by message 20 and when