Hi,

I don't understand how this is supposed to work, because it does simply not.

onException(StoreDataException.class)
            .useOriginalMessage()
            .handled(true)
            .to(errorQueue)
            .markRollbackOnly()
;

Since it's rollbacking, it rollbacks the message to the incoming queue and
not the errorQueue, which reads it again. Chaos.

How can this be handled better?
I'm deploying in liberty profile, and when I'm committing the message to a
queue I want to commit the sql update as well. 

One of my thoughts were using "PROPAGATION_REQUIRES_NEW", so when calling my
bean which calls the database, I'm using that inside an own transaction.
Which will be the only one which rollbacks, and then I can send the message
to the error queue as normal.

But when using "PROPAGATION_REQUIRES_NEW" I get "JtaTransactionManager needs
a JTA TransactionManager for suspending a transaction: specify the
'transactionManager' or 'transactionManagerName' property". I do not get
this error with "PROPAGATION_REQUIRED"

private JmsComponent mqComponentTransacted(InitialContext context, String
connectionFactoryJndiName, String userTransactionJndiName) throws
JMSException, NamingException {
        LOG.info("Setting up JmsComponent using jndi lookup");
        UserTransaction userTransaction = (UserTransaction)
context.lookup(userTransactionJndiName);
        final JtaTransactionManager jtaTransactionManager = new
JtaTransactionManager(userTransaction);
        final ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup(connectionFactoryJndiName);
        final JmsComponent jmsComponent =
JmsComponent.jmsComponentTransacted(connectionFactory,
(PlatformTransactionManager) jtaTransactionManager);
        jmsComponent.setTransacted(false);
       
jmsComponent.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE);

        context.bind("userTransaction", userTransaction);
        context.bind("transactionManager", jtaTransactionManager);

        SpringTransactionPolicy propReq = new SpringTransactionPolicy();
        propReq.setTransactionManager((PlatformTransactionManager)
jtaTransactionManager);
        propReq.setPropagationBehaviorName("PROPAGATION_REQUIRED");
        context.bind("PROPAGATION_REQUIRED", propReq);

        SpringTransactionPolicy propReqNew = new SpringTransactionPolicy();
        propReqNew.setTransactionManager((PlatformTransactionManager)
jtaTransactionManager);
        propReqNew.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW");
        context.bind("PROPAGATION_REQUIRES_NEW", propReqNew);

        return jmsComponent;
    }



--
View this message in context: 
http://camel.465427.n5.nabble.com/Queue-and-database-transaction-rollback-tp5768020.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to