transactional client when hiding infrastructure

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

transactional client when hiding infrastructure

anoordover
We use camel for hiding our infrastructure, which means that we call one or more interface methods from java to put messages on a queue.
In our current configuration we do two method calls in one java-method.
Each call puts a message on a queue.
I am trying to put the two method calls in one transaction which will be rolled back if an exception occurs.
I've added a @Transactional annotation to my method but if an exception occurs between the first and the second method call the jms-message of the first call is still put on the queue.

This is my route definition:
        <camel:camelContext>
                <camel:template id="camelTemplate" />
                <camel:proxy id="beschikkingService" serviceInterface="nl.bedrijf.beschikking.BeschikkingService"
                        serviceUrl="direct:directAsyncQueue" />
                <camel:endpoint id="asyncQueue"
                        uri="activemq:queue:${queue.name.beschikking}" />
                <camel:route id="asyncRoute">
                        <camel:from uri="direct:directAsyncQueue" />
                        <camel:to uri="ref:asyncQueue" />
                </camel:route>
        </camel:camelContext>

Does anybody have any idea how I need to set this up correctly?
Reply | Threaded
Open this post in threaded view
|

Re: transactional client when hiding infrastructure

Christian Mueller
Administrator
Which version of Camel do you use?
How looks your ActiveMQ configuration?

Would somethink like this work for you:
from("activemqTx:queue:transaction.incoming.one")
  .transacted("PROPAGATION_REQUIRED")
  .to("bean:businessService?method=computeOffer")
  .multicast("activemqTx:queue:transaction.outgoing.one",
"activemqTx:queue:transaction.outgoing.two");

You can find more examples at [1].

[1] https://github.com/muellerc/camel-in-transaction/blob/master

Best,
Christian

On Wed, Aug 1, 2012 at 10:20 AM, anoordover <[hidden email]> wrote:

> We use camel for hiding our infrastructure, which means that we call one or
> more interface methods from java to put messages on a queue.
> In our current configuration we do two method calls in one java-method.
> Each call puts a message on a queue.
> I am trying to put the two method calls in one transaction which will be
> rolled back if an exception occurs.
> I've added a @Transactional annotation to my method but if an exception
> occurs between the first and the second method call the jms-message of the
> first call is still put on the queue.
>
> This is my route definition:
>         <camel:camelContext>
>                 <camel:template id="camelTemplate" />
>                 <camel:proxy id="beschikkingService"
> serviceInterface="nl.bedrijf.beschikking.BeschikkingService"
>                         serviceUrl="direct:directAsyncQueue" />
>                 <camel:endpoint id="asyncQueue"
>                         uri="activemq:queue:${queue.name.beschikking}" />
>                 <camel:route id="asyncRoute">
>                         <camel:from uri="direct:directAsyncQueue" />
>                         <camel:to uri="ref:asyncQueue" />
>                 </camel:route>
>         </camel:camelContext>
>
> Does anybody have any idea how I need to set this up correctly?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/transactional-client-when-hiding-infrastructure-tp5716653.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>