The first thing I observe is that exception handlers really should be the
first thing in the route. I dont think the spring DSL enforces this. As to
your question, when you have the message in the transaction and the
transaction fails, the message will end up back in the queue, having never
left it. So if you then send the message back to the queue, you will
duplicate the message in the queue. I would put a tracer on this route and
invoke the exception with a test case then carefully examine the trace. I
think you might find it is being redelivered AND rolled back. The one
question I would have is even if your exception handler is getting called.
Im not so sure it would be judging by its position in the route. A tracer
will tell you the story.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Thu, Feb 6, 2014 at 2:40 PM, praveenbillampati <
praveenbillamp...@gmail.com> wrote:

> Hi All,
>
> We have a camel route processing requests came on to a queue and that queue
> is having concurrent consumers. Route is configured to redeliver the
> message
> for 3 times when there is an exception.
>
> We observed that the same message is getting submitted multiple times and
> there is an increase in the message count on the request q(for a single
> request we are ending up with 1000s of messages(duplicated)) and all are
> ultimately reaching error q slowly if there is some error.
>
> */The understanding I need is if concurrent consumers are enabled, if a
> message is redelivered by a consumer1 with a delay, will that message be
> considered as a new message by consumer2? If so how to skip this
> behavior?/*
>
> Can some one please shed some light on this? Below is the sample route
> configuration
>
> =====================================
> <camelContext id="serviceAdapterContext"
> xmlns="http://camel.apache.org/schema/spring"; trace="false">
>     <route id="order.initialRoute">
>       <from
>
> uri="mqjms:java:comp/env/jms/mq/requestQ?receiveTimeout=30000&amp;recoveryInterval=60000&amp;cacheLevelName=CACHE_CONSUMER&amp;disableReplyTo=true&amp;concurrentConsumers=2"
> />
>       <transacted
> ref="orderService.transactionPolicy.jms.PROPAGATION_REQUIRES_NEW" />
>       <convertBodyTo type="java.io.InputStream" />
>       <unmarshal ref="statusJaxbDataFormat" />
>        <setHeader headerName="ORDER_STATUS">
>         <simple
> resultType="com.xyz.domain.adapter.OrderStatus">${body}</simple>
>       </setHeader>
>       <setBody>
>         <simple>${header.ORDER_STATUS}</simple>
>       </setBody>
>       <setHeader headerName="STATUS">
>         <simple
> resultType="java.lang.String">${body.status.lineStatus[0].status}</simple>
>       </setHeader>
>
>       <choice>
>         <when>
>           <simple>${header.STATUS} == 'A'</simple>
>           <to uri="bean:serviceAdapter?method=processOrder" />
>         </when>
>       </choice>
>
>       <onException useOriginalMessage="true">
>         <exception>java.lang.Exception</exception>
>         <exception>com.xyz.exception.RetryableException</exception>
>         <redeliveryPolicy redeliveryDelay="10000
> retryAttemptedLogLevel="WARN" maximumRedeliveries="3" />
>         <handled>
>           <constant>true</constant>
>         </handled>
>         <log message="An error occurred  ${exception}" loggingLevel="ERROR"
> />
>         <to uri="mqjms:java:comp/env/jms/mq/errorQ" />
>       </onException>
>     </route>
> ==============================================================
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Duplicate-JMS-messages-are-getting-piled-up-with-redelivery-of-messages-tp5746912.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to