You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Carman <ja...@carmanconsulting.com> on 2012/04/20 14:38:35 UTC

Context Component and Transactions...

We are planning to write a bunch of camel contexts which contain
routes using only local endpoints (the vm component).  To get everyone
talking to one another, we'll create a "wiring" context which connects
the dots.  I was wondering how this will work with transactions.
Suppose I have a few routes like this...

In "wiring" context:

from("jms:queue:inputQueue").transacted().to("context:a:in");
from("context:a:out").transacted().to("jms:queue:outputQueue");

In context "a":

from("vm:in").transacted().to(...).to("vm:out");


I assume the transaction won't span through the route in context "a",
correct?  What happens here?  Let's say there's some failure in the
"..." part of my route with a database or something.  The original
message won't go back onto the "inputQueue" will it?  My understanding
is that the transacted() part will start a transaction once the route
begins and try to commit it when the route ends.

Re: Context Component and Transactions...

Posted by Christian Müller <ch...@gmail.com>.
It depends... ;-)

Camel relays on SpringPlatformTransactionManager which is bound to the
current thread,
If you use the "direct" protocol/component, this will be part of this
transaction. If you use the "seda" or "vm" protocol/component (which will
use a different thread), the route in your context component will not be
part of this transaction.

from("vm:in").transacted().to(...).to("vm:out"); make no sense, because the
"vm" component doesn't support transactions, unless your to(...) talks to a
transacted resource.

Best,
Christian

On Fri, Apr 20, 2012 at 2:38 PM, James Carman <ja...@carmanconsulting.com>wrote:

> We are planning to write a bunch of camel contexts which contain
> routes using only local endpoints (the vm component).  To get everyone
> talking to one another, we'll create a "wiring" context which connects
> the dots.  I was wondering how this will work with transactions.
> Suppose I have a few routes like this...
>
> In "wiring" context:
>
> from("jms:queue:inputQueue").transacted().to("context:a:in");
> from("context:a:out").transacted().to("jms:queue:outputQueue");
>
> In context "a":
>
> from("vm:in").transacted().to(...).to("vm:out");
>
>
> I assume the transaction won't span through the route in context "a",
> correct?  What happens here?  Let's say there's some failure in the
> "..." part of my route with a database or something.  The original
> message won't go back onto the "inputQueue" will it?  My understanding
> is that the transacted() part will start a transaction once the route
> begins and try to commit it when the route ends.
>