You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dsemenov <sd...@gmail.com> on 2013/08/01 23:59:00 UTC

Start new route after transaction completed

Hello colleagues

I have a simple route 

<camel:camelContext id="upstream-entries">
        <camel:route>
            <camel:from
uri="execMqOet:PWJMQM.GOM.GOMJULINT.DEV2?disableReplyTo=true"/>
            <camel:onCompletion>
                <camel:to "direct:separate_tx_route" />
                <camel:log message="in on completion" />
            </camel:onCompletion>
            <camel:transacted ref="PROPAGATION_REQUIRED"/>
            <camel:to uri="sql:INSERT INTO DISASTER values
(SEQ_TFI_TRADE_STATUS.NEXTVAL, #)?dataSourceRef=xaDataSource"/>
        </camel:route>
    </camel:camelContext>

execMqOet is a transactional jms consumer which starts XA transaction. 
I need to start another transaction in direct:separate_tx_route but it
should be started only if transaction finished in parent route.

After some investigation i've found that onCompletion starts in another
thread (which is fine), when exchange is completed. But this doesn't mean
that transaction in parent route committed as well.

How can i synchronize on completion block with transaction commit in parent
route?



--
View this message in context: http://camel.465427.n5.nabble.com/Start-new-route-after-transaction-completed-tp5736661.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Start new route after transaction completed

Posted by dsemenov <sd...@gmail.com>.
Thank you Claus

That what we tried to do
But we need to see results of initial transaction in new one. however that
is not always the true, because new one may start before initial committed.

Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/Start-new-route-after-transaction-completed-tp5736661p5736704.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Start new route after transaction completed

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

You cannot do this using onCompletion. For 2 different TX in the same
unit of work, you can use the propagation behaviors with REQUIRES_NEW
to start a new TX for the 2nd part.

This use-case is covered in Camel in Action book from page 305 onwards.

On Thu, Aug 1, 2013 at 11:59 PM, dsemenov <sd...@gmail.com> wrote:
> Hello colleagues
>
> I have a simple route
>
> <camel:camelContext id="upstream-entries">
>         <camel:route>
>             <camel:from
> uri="execMqOet:PWJMQM.GOM.GOMJULINT.DEV2?disableReplyTo=true"/>
>             <camel:onCompletion>
>                 <camel:to "direct:separate_tx_route" />
>                 <camel:log message="in on completion" />
>             </camel:onCompletion>
>             <camel:transacted ref="PROPAGATION_REQUIRED"/>
>             <camel:to uri="sql:INSERT INTO DISASTER values
> (SEQ_TFI_TRADE_STATUS.NEXTVAL, #)?dataSourceRef=xaDataSource"/>
>         </camel:route>
>     </camel:camelContext>
>
> execMqOet is a transactional jms consumer which starts XA transaction.
> I need to start another transaction in direct:separate_tx_route but it
> should be started only if transaction finished in parent route.
>
> After some investigation i've found that onCompletion starts in another
> thread (which is fine), when exchange is completed. But this doesn't mean
> that transaction in parent route committed as well.
>
> How can i synchronize on completion block with transaction commit in parent
> route?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Start-new-route-after-transaction-completed-tp5736661.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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