Thanks for the feedback.

I change my route definition into the below:

        <camel:camelContext xmlns="http://camel.apache.org/schema/spring"; 
id="camelContext">

                <endpoint id="async.internal.inbound.endpoint" 
uri="jms:queue:GEPQ.QL.IN_PRINT_CONFIRM.0001?exchangePattern=InOnly" />

                <camel:route>
                        <camel:from uri="ref:async.internal.inbound.endpoint" />
                        <camel:transacted ref="required" />
                        <camel:filter>
                                <camel:method bean="headerRedeliveryFilter" 
method="isRedeliveryCountExceeded" />
                                <camel:to 
uri="jms:queue:GEPQ.QL.IN_PRINT_CONFIRM_BO.0001" />
                                <camel:stop/>
                        </camel:filter>

                        <camel:process ref="asyncInternalEndpointImpl" />

                        <camel:onException >
                                
<camel:exception>java.lang.Throwable</camel:exception>
                                <camel:handled>
                                        <constant>true</constant>
                                </camel:handled>
                                <camel:rollback markRollbackOnly="true" />
                        </camel:onException>
                        
                </camel:route>

        </camel:camelContext>

So basically I rollback in case of any exception and for each incoming message 
I test the header JMSXDeliveryCount in the filter. If it exceeds a value, I 
send the message to a backout queue and stop the route processing.

The code for the bean used in the filter looks like

                String redeliveryCountAsString = 
exchange.getIn().getHeader("JMSXDeliveryCount", String.class);
                if (logger.isDebugEnabled())
                {
                        logger.debug("redeliveryCount: " + 
redeliveryCountAsString);
                }
                int redeliveryCount = Integer.parseInt(redeliveryCountAsString);
                if (redeliveryCount > maxRedeliveryCount)
                {
                        return true;
                }
                else
                {
                        return false;
                }

Kr,

Frederik.



-----Original Message-----
From: David Karlsen [mailto:davidkarl...@gmail.com] 
Sent: vrijdag 9 november 2012 17:01
To: users@camel.apache.org
Subject: Re: Rollback and redeliver JMS message between Websphere and MQ via 
Camel

Configure number of redeliveries to be 0. You might also be interested in 
looking into the docs for the transactional error handler which is default for 
transacted routes.
Den 9. nov. 2012 10:09 skrev "De Backer Frederik (Belfius)" < 
frederik.debac...@belfius.be> følgende:

> Hello,
>
> I have a message driven bean deployed in a Websphere 8.0 server that 
> is consuming messages from a Websphere MQ message broker. I would like 
> to replace the MDB by a Camel JMS component but I have some issues 
> regarding the proper handling of message rollback and XA transactions. 
> The message processing does database updates. If an exception occurs 
> during this database update (or any other runtime exception occurs) 
> then the database updates and the message reception need to be 
> rollbacked (placing the message back on the qeue). Up to three 
> redeliveries occur after which the WAS message listener puts the 
> message in a backout queue. This setup is currently working.
> I tried to mimick this behaviour with Camel but have been 
> unsuccessfull until now.
>
> What I see is that Camel itself retries 3 times (without putting back 
> the message onto the queue). Only after doing three retries, Camel 
> rollbacks the transaction and the message is put back on the queue 
> after which it is again redelivered from the queue.
>
> What I would like however is that Camel itself doesn't do a retry but 
> immediately rollbacks the message to the queue if an exception occurs. 
> If Camel notices that three redeliveries from the queue have been done 
> (this can be checked via a custom JMS header property that is set by 
> MQ and that indicates the number of redeliveries) then the message has 
> to be placed on a backout queue by Camel.
>
> I already looked around but until now I have no idea how I can 
> implement this use case.
>
> Below you can find my Camel config file. I am using Camel 2.10.1.
>
> Any help would be greatly appreciated.
>
> kind regards,
>
> Frederik.
>
>
>         <bean id="required"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>                 <property name="transactionManager"
> ref="transactionManager" />
>                 <property name="propagationBehaviorName"
> value="PROPAGATION_REQUIRED" />
>         </bean>
>
>         <camel:camelContext xmlns="http://camel.apache.org/schema/spring";
> id="camelContext">
>                 <endpoint id="async.internal.inbound.endpoint"
> uri="jms:queue:GEPQ.QL.IN_PRINT_CONFIRM.0001?exchangePattern=InOnly" />
>                 <camel:route>
>                         <camel:from
> uri="ref:async.internal.inbound.endpoint" />
>                         <camel:transacted ref="required" />
>                         <camel:process ref="asyncInternalEndpointImpl" />
>                         <camel:onException >
>
> <camel:exception>java.lang.Throwable</camel:exception>
>                                 <camel:redeliveryPolicy 
> redeliveryDelay="5000" maximumRedeliveries="3"></camel:redeliveryPolicy>
>                                 <camel:handled>
>                                         <constant>false</constant>
>                                 </camel:handled>
>                                 <camel:to 
> uri="jms:queue:GEPQ.QL.IN_PRINT_CONFIRM_BO.0001" />
>                                 <camel:rollback markRollbackOnly="true" />
>                         </camel:onException>
>
>                 </camel:route>
>
>         </camel:camelContext>
>
>         <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="connectionFactory"
> ref="geosConnectionFactory" />
>                 <property name="concurrentConsumers" value="1" />
>                 <property name="maxConcurrentConsumers" value="10" />
>                 <property name="cacheLevelName" value="CACHE_NONE" />
>                 <!--<property name="transacted" value="false" />-->
>                 <property name="transactionManager"
> ref="transactionManager" />
>                 <property name="taskExecutor" ref="wasTaskExecutor" />
>                 <property name="disableReplyTo" value="true" />
>                 <property name="errorHandlerLoggingLevel" value="DEBUG" />
>         </bean>
>
> Frederik De Backer
>
> Belfius
> ITDEV/DCAR/DART
>
> * DT 16 / 37
> * 02/22 25252
> * mailto:frederik.debac...@belfius.be  | www.belfius.be
>
>
>
>
> ----------------------------------------------------------------------
> -------
>
> http://www.belfius.be/maildisclaimer.htm
>
>
> ----------------------------------------------------------------------
> -------
>
-----------------------------------------------------------------------------

http://www.belfius.be/maildisclaimer.htm

-----------------------------------------------------------------------------

Reply via email to