camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: JTA Transactions not rolling back in RouteBuilder
Date Mon, 11 May 2009 06:09:23 GMT
On Mon, May 11, 2009 at 7:46 AM, triswork <tristan.koen@gmail.com> wrote:
>
> I have made some progress with this issue, but I am more confused than
> ever...
> If I annotate my poll() method with @Transactional(propagation =
> Propagation.MANDATORY) I get:
> IllegalTransactionStateException: No existing transaction found for
> transaction marked with propagation 'mandatory'
Hi

Just to be sure. You have that Spring XML configuration for doing TX
annotations in there?
See more at:
http://static.springframework.org/spring/docs/2.5.x/reference/transaction.html#transaction-declarative-annotations


>
> If, however, I rewrite my poll() method to use use programmatic rather than
> declarative transaction support, everything works as expected. The revised
> code is:
>
> protected void poll() throws Exception {
>    PlatformTransactionManager transactionMananger =
> endpoint.getTransactionManager();
>    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
>    TransactionStatus status = transactionMananger.getTransaction(def);
>    try {
>        List<Map> items =
> endpoint.getMessageQueueDao().processQueue(batchSize);
>        for (Map m : items) {
>            Exchange exchange = endpoint.createExchange();
>            exchange.getIn().setBody(m);
>            getProcessor().process(exchange);
>            transactionMananger.commit(status);
>        }
>    }
>    catch (Exception ex) {
>        LOG.error("EXCEPTION THROWN DURING TRANSACTION:" + ex.toString());
>        transactionMananger.rollback(status);
>    }
> }
>
> Can anyone shed some light on this?
> --
> View this message in context: http://www.nabble.com/JTA-Transactions-not-rolling-back-in-RouteBuilder-tp23457761p23477404.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress

Mime
View raw message