camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Some questions of camel's jta transaction support
Date Fri, 26 Nov 2010 08:52:58 GMT

Camel in Action chapter 9 really covers transaction and compensations
really well.

On Fri, Nov 26, 2010 at 6:06 AM, ext2 <> wrote:
> 1: Could the from-endpoint decide how to do the post-action  according to
> following  route's transaction result(rollback/commit)?
>  Fo example :
>        from().transacted().multicast().db1().db2();
>        from() will receive a external message. Db1, db2 will insert the
> message to different database; and a jta-transaction is controlling the two
> database resource.
>        Now we wish the (from) external system's message will be delete only
> when the both database operation succeed. If one of it failed, the other
> database will rollback, and the (from) external system's message will also
> be reserved;
>        If the the (from) external system is a transactional-resource, etc:
> jms or database, there will no problem;
>        But if the (from) external system is file(or some other, etc: email,
> ftp), could the camel's file component can delete or reserve the file
> according to the result of jta-transaction?

The Camel file component support this as it will only delete/moved the
file if its successful processed.
It checks the Exchange if an exception was thrown or not.

> 2) When using multi jta transaction in one exchange, it must be separate to
> different route using direct-endpoint; But if so, when transactions  is
> nested; and inner's exception occurs,how does the outer transaction deal
> with the exception? Outer transaction will ignore the exception and commit,
> or treat it as exception and rollback?
>  let's take a example:
>        {a,{b,c}d}
> The route has 4 processor, now [a,.. ,d] belong to a jta transaction, [b-c]
> belong to a new jta  transaction;
> Camel will ask for configure it as two route:
>        From().transacted(required).a().to("direct:x").d();
>        From("direct:x").transacted().b().c();
> So if b or c raise exception in the inner transaction's route, how does the
> outer transaction do? Rollback or commit ?

Check the book as it has such an example, where you can decide that
the inner should rollback, but the outer should still commit.
Camel got some options for that, such as rollbackLocalOnly()

And also try out yourself to see what happens.

> 3)  If I using multi transaction in one exchange , must I separate the it to
> diff route using direct-endpoint?
>        ...actually, I find a un-document ways to use the multi camel
> transaction, which need not separate route . That's just configure the
> camel's transaction as a policy.
>        A few month ago, I have ask the question. And the answer is the
> camel's 2.1 doesn't support configured policy. But now camel's 2.5 is
> published, could it support such a usage?

Claus Ibsen
Twitter: davsclaus
Author of Camel in Action:

View raw message