camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <>
Subject Re: Distributed transaction in camel route
Date Mon, 17 Sep 2012 02:29:17 GMT
Something like this:

On Sun, Sep 16, 2012 at 12:53 PM, Raul Kripalani <> wrote:
> Hi James,
> By using singular transactions rather than distributed transactions (XA),
> each resource involved is responsible for managing its own transaction, i.e.
> the JMS session and the JDBC DataSource will run separate transactions.
> Camel has a concept called "Unit of Work" that is used to synchronise
> transactions, or quasi-transactional behaviour, across several endpoints in
> a route. An example of a "quasi-transactional" action is found in the File
> consumer endpoint, where the file only will be moved to the "done" directory
> if the route hasn't failed. Otherwise it will be moved to the "failed"
> directory.
> In the scenario that Christian proposes, the JMS consumer will begin a
> transaction and will wait till the Exchange is done. At that point, it will
> decide whether to commit or rollback the transaction depending on if there's
> an Exception set or not in the Exchange. This way, you don't get full XA
> behaviour, but you get something pretty close. There's still a risk of JMS
> and JDBC becoming falling out of sync if Camel crashes after JDBC commits
> but before the JMS endpoint is notified of the DONE exchange and commits the
> local transaction there.
> To use this approach, you want to set transacted=true at the JMS consumer,
> so that the JMS endpoint will manage its transaction.
> On the other hand, XA is a different story. With XA, you don't want Camel to
> manage the transaction (you set transacted=false on the endpoint), because
> the XAResource will enlist itself in the transaction automatically. If you
> set transacted=true with XA, you'll begin to see exceptions due to the JMS
> XAResouce being enlisted twice.
> While I worked at FuseSource, Charles Moulliard and I created examples
> showing both:
> a) XA Transactions involving JMS and JDBC
> b) JMS + JDBC local transactions
> You can find the source code here: [1] and [2]. Here is a video with the
> demo: [3], and the full webinar is split in two parts: [4] and [5].
> Hope that helps!
> Raúl.
> ---
> Raúl Kripalani
> Enterprise Architect, Program Manager, Open Source Integration specialist
> |
> | twitter: @raulvk
> [1]
> [2]
> [3]
> [4]
> [5]
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

View raw message