You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marco Zapletal <ma...@gmail.com> on 2012/09/01 16:04:01 UTC
Wait for transaction commit when putting messages on JMS queue using
inOnly
Hi Camel folks,
I have the following route configuration
from("activemq:q1").
transacted().
...
.inOnly("activemq:q2").
.inOnly("custom:storeMonitoringInformation")
The goal of the second .inOnly ("custom:storeMonitoringInformation") is
to store some monitoring information about the message after it was been
enqueued in q2. However, in case that the transaction commit fails
(i.e., the message could not be inserted in q2), the monitoring entry is
stored anyway.
What is the recommended solution to deal with this issue - i.e., to wait
for a successful transaction commit before continuing with the route.
Thanks and best regards,
Marco
Re: Wait for transaction commit when putting messages on JMS queue
using inOnly
Posted by Marco Zapletal <ma...@gmail.com>.
On 06.09.2012 11:33, Claus Ibsen wrote:
> Hi
>
> I assume the custom logic cannot participate in the same TX as the activeMQ?
Right. The custom logic should only execute upon successful completion
of the transaction.
>
> You can use onCompletion to store the monitoring after the routing has
> completed. Then you can check if it was failed or not. And then only
> store when not failed.
> http://camel.apache.org/oncompletion.html
Thanks. We are using now onCompletion().onCompleteOnly()
>
> However since the TX is using the same ActiveMQ to both consume + send
> a message to it. Then there is a very slight slight slight chance that
> the TX cannot complete.
>
> Have you actually seen any situations where the TX could not commit?
>
Yes, in the past. We are using ActiveMQ with JDBC and there were
situations where the connection to the DB was lost (when using the
standard JDBC configuration). Then the commit failed in the first
attempt, but succeeeded the second time resulting in executing the
custom logic twice.
>
>
> On Sat, Sep 1, 2012 at 4:04 PM, Marco Zapletal <ma...@gmail.com> wrote:
>> Hi Camel folks,
>>
>>
>> I have the following route configuration
>>
>> from("activemq:q1").
>> transacted().
>> ...
>> .inOnly("activemq:q2").
>> .inOnly("custom:storeMonitoringInformation")
>>
>>
>> The goal of the second .inOnly ("custom:storeMonitoringInformation") is to
>> store some monitoring information about the message after it was been
>> enqueued in q2. However, in case that the transaction commit fails (i.e.,
>> the message could not be inserted in q2), the monitoring entry is stored
>> anyway.
>>
>> What is the recommended solution to deal with this issue - i.e., to wait for
>> a successful transaction commit before continuing with the route.
>>
>> Thanks and best regards,
>>
>> Marco
>
>
>
Re: Wait for transaction commit when putting messages on JMS queue
using inOnly
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I assume the custom logic cannot participate in the same TX as the activeMQ?
You can use onCompletion to store the monitoring after the routing has
completed. Then you can check if it was failed or not. And then only
store when not failed.
http://camel.apache.org/oncompletion.html
However since the TX is using the same ActiveMQ to both consume + send
a message to it. Then there is a very slight slight slight chance that
the TX cannot complete.
Have you actually seen any situations where the TX could not commit?
On Sat, Sep 1, 2012 at 4:04 PM, Marco Zapletal <ma...@gmail.com> wrote:
> Hi Camel folks,
>
>
> I have the following route configuration
>
> from("activemq:q1").
> transacted().
> ...
> .inOnly("activemq:q2").
> .inOnly("custom:storeMonitoringInformation")
>
>
> The goal of the second .inOnly ("custom:storeMonitoringInformation") is to
> store some monitoring information about the message after it was been
> enqueued in q2. However, in case that the transaction commit fails (i.e.,
> the message could not be inserted in q2), the monitoring entry is stored
> anyway.
>
> What is the recommended solution to deal with this issue - i.e., to wait for
> a successful transaction commit before continuing with the route.
>
> Thanks and best regards,
>
> Marco
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen