You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tolk <jm...@hotmail.com> on 2012/11/30 12:01:00 UTC

Spring Transaction Propagating?

I have a situation similar to the simplified example below. Basically, I'm
trying to use camel on an internal service to send an async message to
itself via the SEDA component - a little odd perhaps but I don't have any
choice in this:

public class MyServiceImpl
{
	ProducerTemplate producerTemplate;
	
	...
	
	@Transactional(propagation = Propagation.REQUIRED)
	public void startingMethod(...)
	{
		...
		producerTemplate.sendMessage("seda:start"...);
	}

	public void endingMethod(...)
	{
		...
	}
}

public class MyRouteBuilder extends RouteBuilder
{
	public void configure()
	{
		from("seda:start").to("bean:myServiceImplBean?method=endingMethod");
	}
}

My questions are; what will happen to the spring transaction delimitated by
the annotation, will it be lost? If so is there a way to propagate this
transaction using camel?

Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Spring Transaction Propagating?

Posted by tolk <jm...@hotmail.com>.
Not sure I follow (I'm newish to Camel and Spring TX). So basically it can't
be done, so I'll be better off setting up functionality so that I can start
my transaction at the consumer method rather than the producer to avoid
changing thread during the transaction?

Cheers for the help.



--
View this message in context: http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723449.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Spring Transaction Propagating?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Nov 30, 2012 at 12:41 PM, tolk <jm...@hotmail.com> wrote:
> I noticed Camel has some functionality relating to transactional behaviour.
> Is this just internal transactional behaviour then i.e. only over the camel
> communication itself?
>

No it integrates with Spring TX. And ensures the route is run under
the orchestration of the Spring TX manager.
eg deep down there is some code that runs inside a Spring
doInTransaction() method.



> Thanks.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723447.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Spring Transaction Propagating?

Posted by tolk <jm...@hotmail.com>.
I noticed Camel has some functionality relating to transactional behaviour.
Is this just internal transactional behaviour then i.e. only over the camel
communication itself?

Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442p5723447.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Spring Transaction Propagating?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

No you can't propagate spring TX accross different threads.


On Fri, Nov 30, 2012 at 12:01 PM, tolk <jm...@hotmail.com> wrote:
> I have a situation similar to the simplified example below. Basically, I'm
> trying to use camel on an internal service to send an async message to
> itself via the SEDA component - a little odd perhaps but I don't have any
> choice in this:
>
> public class MyServiceImpl
> {
>         ProducerTemplate producerTemplate;
>
>         ...
>
>         @Transactional(propagation = Propagation.REQUIRED)
>         public void startingMethod(...)
>         {
>                 ...
>                 producerTemplate.sendMessage("seda:start"...);
>         }
>
>         public void endingMethod(...)
>         {
>                 ...
>         }
> }
>
> public class MyRouteBuilder extends RouteBuilder
> {
>         public void configure()
>         {
>                 from("seda:start").to("bean:myServiceImplBean?method=endingMethod");
>         }
> }
>
> My questions are; what will happen to the spring transaction delimitated by
> the annotation, will it be lost? If so is there a way to propagate this
> transaction using camel?
>
> Thanks!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Spring-Transaction-Propagating-tp5723442.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen