You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by gnanda <gi...@phaseforward.com> on 2010/05/04 19:53:18 UTC
smx4:camel2.2 transactional error handling
Hi All,
I upgraded my code from smx4.0 to smx4.2 to get better error handling
feature with transaction support.
But looks like it is not doing as I was expecting. I could get onException
block works with transactional route. But if the transaction fail at the
end, it does not go to DeadLetterQueue which I configured in
activemq-broker.xml file. After reading the documents I got to know that
transactionalErrorHandler ignores DLQ setting.
We cannot afford loosing any message in our scenario.
Is there any way I could configure the transactionErrorHandler to reroute
the message to any other queue (example "errorQ") in case of failure?
Please help.
--
View this message in context: http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28450957.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: smx4:camel2.2 transactional error handling
Posted by gnanda <gi...@phaseforward.com>.
I would like to take back my statement regarding "The transactional error
handling is working". It is not working in all the scenarios.
I have a call to external web service as my target endpoint. If the target
endpoint receives the message but returns a soap fault or any error then the
message is routed to DLQ but many other exceptions like
java.net.ConnectException (when external web service is down) or
nullpointerException( if the incoming soap message is not in expected
format) then the message is not getting routed to DLQ
For the time being I am using onException block to route to errorQ not to
loose the message
gnanda wrote:
>
> Hi All,
> looks like the error handling is working. I had a bug in my code and that
> was raising exception, that exception was not re-routing it to DLQ. It was
> routing to Q attached to onException() route.
> If I have any exception on exchanging with external endpoint then it is re
> routing it to DLQ
>
> Thank you all
>
> The error handling is working
>
> gnanda wrote:
>>
>> Hi All,
>> I upgraded my code from smx4.0 to smx4.2 to get better error handling
>> feature with transaction support.
>>
>> But looks like it is not doing as I was expecting. I could get
>> onException block works with transactional route. But if the transaction
>> fail at the end, it does not go to DeadLetterQueue which I configured in
>> activemq-broker.xml file. After reading the documents I got to know that
>> transactionalErrorHandler ignores DLQ setting.
>>
>> We cannot afford loosing any message in our scenario.
>>
>> Is there any way I could configure the transactionErrorHandler to reroute
>> the message to any other queue (example "errorQ") in case of failure?
>>
>> Please help.
>>
>>
>
>
--
View this message in context: http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28512482.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: smx4:camel2.2 transactional error handling
Posted by gnanda <gi...@phaseforward.com>.
Hi All,
looks like the error handling is working. I had a bug in my code and that
was raising exception, that exception was not re-routing it to DLQ. It was
routing to Q attached to onException() route.
If I have any exception on exchanging with external endpoint then it is re
routing it to DLQ
Thank you all
The error handling is working
gnanda wrote:
>
> Hi All,
> I upgraded my code from smx4.0 to smx4.2 to get better error handling
> feature with transaction support.
>
> But looks like it is not doing as I was expecting. I could get onException
> block works with transactional route. But if the transaction fail at the
> end, it does not go to DeadLetterQueue which I configured in
> activemq-broker.xml file. After reading the documents I got to know that
> transactionalErrorHandler ignores DLQ setting.
>
> We cannot afford loosing any message in our scenario.
>
> Is there any way I could configure the transactionErrorHandler to reroute
> the message to any other queue (example "errorQ") in case of failure?
>
> Please help.
>
>
--
View this message in context: http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28466030.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: smx4:camel2.2 transactional error handling
Posted by gnanda <gi...@phaseforward.com>.
Thanks Claus for the reply.
Do you have any example how to set DLQ for smx4.2. I tried setting DLQ in
activemq-broker.xml as below, but has no effect.
Do I need to set my error handler to DeadletterChannel somehow instead of
transactionErrorHandler?
activemw-broker destinationPolicy setting:
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" producerFlowControl="true"
memoryLimit="1mb">
<pendingSubscriberPolicy>
<vmCursor />
</pendingSubscriberPolicy>
</policyEntry>
<policyEntry queue=">" producerFlowControl="true"
memoryLimit="1mb">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix="DLQ."
useQueueForQueueMessages="true" />
</deadLetterStrategy> <!--
Use VM cursor for better latency
For more information, see:
http://activemq.apache.org/message-cursors.html
<pendingQueuePolicy>
<vmQueueCursor/>
</pendingQueuePolicy>
-->
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
Here is my camel_context.xml
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://LPF004689:61616" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" /> <!--
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="transacted" value="true" />
-->
</bean>
<bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="1" />
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="concurrentConsumers" value="5" />
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="transacted" value="true" />
<property name="deliveryPersistent" value="true"/>
<property name="explicitQosEnabled" value="true"/>
</bean>
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" />
</bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
trace="true">
<package>com.pf.simplecamelconsumer</package>
</camelContext>
</beans>
MyRouterBuilder configure method:
public void configure() {
MyProcessorBean myBean = new
com.pf.simplecamelconsumer.MyProcessorBean();
//do not need to create one, automatically discover it
//SpringTransactionPolicy transactionPolicy =
bean(SpringTransactionPolicy.class, "PROPAGATION_REQUIRED");
onException(Throwable.class).maximumRedeliveries(1).handled(false).process(new
MyErrorHandler());
from("jms:queue:queue1").transacted("PROPAGATION_REQUIRED")
.bean(myBean,"setLocationUrI")
.recipientList(header(Constants.DYNAMIC_HTTP_URI)).bean(myBean,"printResponse");
}
Claus Ibsen-2 wrote:
>
> On Tue, May 4, 2010 at 7:53 PM, gnanda <gi...@phaseforward.com>
> wrote:
>>
>> Hi All,
>> I upgraded my code from smx4.0 to smx4.2 to get better error handling
>> feature with transaction support.
>>
>> But looks like it is not doing as I was expecting. I could get
>> onException
>> block works with transactional route. But if the transaction fail at the
>> end, it does not go to DeadLetterQueue which I configured in
>> activemq-broker.xml file. After reading the documents I got to know that
>> transactionalErrorHandler ignores DLQ setting.
>>
>
> Yes it does. If the message was set to rollback or an exception was
> not handled, then the JMS will receive this error.
> And if you have JMS Broker configured to move to DLQ after X attempts
> it will do so.
>
> I assume you may have configured JMS Broker to move to DLQ after 6
> attempts, and then you have Camel configured to retry X times as well.
> That gives you total 6 * X times.
>
>
>
>
>> We cannot afford loosing any message in our scenario.
>>
>
> Let the JMS Broker handle the redelivery and move to DLQ after X attempts.
> It has various options to configure this.
>
>
>> Is there any way I could configure the transactionErrorHandler to reroute
>> the message to any other queue (example "errorQ") in case of failure?
>>
>> Please help.
>>
>> --
>> View this message in context:
>> http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28450957.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
--
View this message in context: http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28461083.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: smx4:camel2.2 transactional error handling
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, May 4, 2010 at 7:53 PM, gnanda <gi...@phaseforward.com> wrote:
>
> Hi All,
> I upgraded my code from smx4.0 to smx4.2 to get better error handling
> feature with transaction support.
>
> But looks like it is not doing as I was expecting. I could get onException
> block works with transactional route. But if the transaction fail at the
> end, it does not go to DeadLetterQueue which I configured in
> activemq-broker.xml file. After reading the documents I got to know that
> transactionalErrorHandler ignores DLQ setting.
>
Yes it does. If the message was set to rollback or an exception was
not handled, then the JMS will receive this error.
And if you have JMS Broker configured to move to DLQ after X attempts
it will do so.
I assume you may have configured JMS Broker to move to DLQ after 6
attempts, and then you have Camel configured to retry X times as well.
That gives you total 6 * X times.
> We cannot afford loosing any message in our scenario.
>
Let the JMS Broker handle the redelivery and move to DLQ after X attempts.
It has various options to configure this.
> Is there any way I could configure the transactionErrorHandler to reroute
> the message to any other queue (example "errorQ") in case of failure?
>
> Please help.
>
> --
> View this message in context: http://old.nabble.com/smx4%3Acamel2.2-transactional-error-handling-tp28450957p28450957.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: smx4:camel2.2 transactional error handling
Posted by Willem Jiang <wi...@gmail.com>.
After going through the code, I can confirm you the
transactionErrorHandler ignore the DeadLetter setting.
I think you can put the failed Exchange into the DeadLetterQueue by
using the onException.
If it can solve your problem , please feel free to log a JIRA[1] for it.
[1]https://issues.apache.org/activemq/browse/CAMEL
Willem
gnanda wrote:
> Hi All,
> I upgraded my code from smx4.0 to smx4.2 to get better error handling
> feature with transaction support.
>
> But looks like it is not doing as I was expecting. I could get onException
> block works with transactional route. But if the transaction fail at the
> end, it does not go to DeadLetterQueue which I configured in
> activemq-broker.xml file. After reading the documents I got to know that
> transactionalErrorHandler ignores DLQ setting.
>
> We cannot afford loosing any message in our scenario.
>
> Is there any way I could configure the transactionErrorHandler to reroute
> the message to any other queue (example "errorQ") in case of failure?
>
> Please help.
>