Hi, I have tried with OnException and doTry/doCatch error handler still I am getting the same behaviour as message sends to JMS_ONE.
error handler <onException redeliveryPolicyRef="myRedelivery"> <exception>java.lang.RuntimeException</exception> <exception>java.lang.IllegalArgumentException</exception> <handled> <constant>true</constant> </handled> <!--<rollback markRollbackOnly="true"/>--> <to uri="direct:dead_letter_channel"/> </onException> <route id="direct_dead_letter_channel"> <from uri="direct:dead_letter_channel"/> <transacted/> <process ref="deadChannelProcessor"/> <to uri="jmserror:queue:ERROR"/> </route> I have tried with adding rollback in error handler, in that case message not written to JMS_ONE queue, it has redelivered message to source queue JMS_IN for some count but finally, it has not sent the message to ERROR. Kindly advise if I miss anything!!! On Wed, 26 Jun 2019 at 13:25, Claus Ibsen <claus.ib...@gmail.com> wrote: > Hi > > You are using dead letter channel as Camel's error handler which will > mark the message as succesfull. > Just use a regular error handler > > On Wed, Jun 26, 2019 at 9:50 AM sujin sr <suji...@gmail.com> wrote: > > > > Thanks for the Response. > > > > Before implementing 'transacted JMS acknowledge' i have tried to create > > separate JMS component for ERROR. But still, I see the same behaviour as > > message sent to the JMS_ONE not rollbacked > > > > I have added this beans and changed ERROR route like below > > > > <bean id="jmsConfigError" > > class="org.apache.camel.component.jms.JmsConfiguration"> > > <property name="connectionFactory" ref="jmsConnectionFactory"/> > > </bean> > > > > <bean id="jmserror" class="org.apache.camel.component.jms.JmsComponent"> > > <property name="configuration" ref="jmsConfigError"/> > > </bean> > > > > > > <route id="direct_dead_letter_channel"> > > <from uri="direct:dead_letter_channel"/> > > <transacted/> > > <process ref="deadChannelProcessor"/> > > <to uri="jmserror:queue:ERROR"/> > > </route> > > > > Where i am missing anything here, kindly advise!!!! > > > > > > > > On Wed, 26 Jun 2019 at 12:51, Claus Ibsen <claus.ib...@gmail.com> wrote: > > > > > Hi > > > > > > Its likely better to use just the brokers error handling with > > > transaction (transacted JMS acknowledge). > > > Then you can configure the broker with redelivery and its dead letter > > > queue. > > > Then you dont need any Camel error handler, and only need to setup JMS > > > component for transacted JMS ack mode. > > > > > > Otherwise in your use case, you cannot both rollback sending to ONE > > > and TWO but send to ERROR as they are all in the same transaction. > > > So in this example you need to setup a 2nd JMS component for ERROR, so > > > the JMS can rollback, and ERROR can commit. Also mind that the > > > incoming endpoint is also JMS and it will also rollback as part of ONE > > > and TWO. So you will get the message redelibered again from the > > > broker. > > > > > > So try instead to just use broker error handling. > > > > > > > > > > > > > > > On Wed, Jun 26, 2019 at 9:01 AM sujin sr <suji...@gmail.com> wrote: > > > > > > > > I am facing a issue while trying to implement JMS transaction using > > > Camel. > > > > > > > > Here is the scenario > > > > > > > > 1. Primary route which read the message from the queue(JMS_IN), pass > the > > > > same exchange to the two sub route(direct route) > > > > 2. First sub route process the message successfully and send to the > > > another > > > > queue(JMS_ONE) > > > > 3. Second sub route process the message and send to the another > > > > queue(JMS_TWO). > > > > 4. If any error occurred during the sub route processing all the > message > > > > should rollback and original message sent to another queue(ERROR) > that is > > > > dead letter queue. > > > > 5. In the example Context I have created throw RuntimeException > during > > > > second sub route processing. > > > > 6. So expected behavior is to move the original message to ERROR > queue, > > > > same time no message should send to JMS_ONE & JMS_TWO > > > > 7. But actual behavior is original message was sent to the ERROR > queue, > > > but > > > > message sent the JMS_ONE. > > > > > > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > > > > manager. > > > > > > > > Kindly help me on this, I am struck at this for couple of days > > > > > > > > Camel Context Below > > > > > > > > <bean id="jndiTemplate" > class="org.springframework.jndi.JndiTemplate"> > > > > <property name="environment"> > > > > <props> > > > > <prop > > > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop> > > > > <prop > > > > key="java.naming.provider.url">http-remoting://localhost:9089</prop> > > > > <!--<prop > > > > > > > > key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>--> > > > > <prop > key="java.naming.security.principal">TESTUSR</prop> > > > > <prop > > > key="java.naming.security.credentials">TESTUSR</prop> > > > > </props> > > > > </property> > > > > </bean> > > > > > > > > <bean id="jmsTemplate" > > > class="org.springframework.jms.core.JmsTemplate"> > > > > <property name="connectionFactory" > ref="jmsConnectionFactory"/> > > > > </bean> > > > > > > > > <bean id="jmsConnectionFactory" > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > <property name="jndiTemplate" ref="jndiTemplate"/> > > > > <property name="jndiName" > value="jms/RemoteConnectionFactory"/> > > > > </bean> > > > > > > > > <bean id="jmsTransactionManager" > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > <property name="connectionFactory" > ref="jmsConnectionFactory"/> > > > > </bean> > > > > > > > > <bean id="jmsConfig" > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > <property name="connectionFactory" > ref="jmsConnectionFactory"/> > > > > <property name="transactionManager" > ref="jmsTransactionManager"/> > > > > <property name="transacted" value="true"/> > > > > </bean> > > > > > > > > <bean id="jms" > class="org.apache.camel.component.jms.JmsComponent"> > > > > <property name="configuration" ref="jmsConfig"/> > > > > </bean> > > > > > > > > <bean id="successProcessor" > class="com.test.SuccessTestProcessor"/> > > > > <bean id="errorProcessor" class="com.test.ErrorTestProcessor"/> > > > > <bean id="deadChannelProcessor" > > > > class="com.test.DeadChannelTestProcessor"/> > > > > > > > > > > > > <bean id="myDeadLetterErrorHandler" > > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > > > <property name="deadLetterUri" > > > value="direct:dead_letter_channel"/> > > > > <property name="redeliveryPolicy" > > > ref="myRedeliveryPolicyConfig"/> > > > > </bean> > > > > > > > > <bean id="myRedeliveryPolicyConfig" > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > <property name="maximumRedeliveries" value="0"/> > > > > </bean> > > > > > > > > <camelContext xmlns="http://camel.apache.org/schema/spring" > > > > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > <route id="route-one" > > > > > <from uri="jms:queue:t24IFInboundQueue"/> > > > > <transacted/> > > > > <to uri="direct:success-route"/> > > > > <to uri="direct:error-route"/> > > > > </route> > > > > > > > > <route id="direct-success-route"> > > > > <from uri="direct:success-route"/> > > > > <transacted/> > > > > <process ref="successProcessor"/> > > > > <to uri="jms:queue:JMS_ONE"/> > > > > </route> > > > > > > > > <route id="direct-error-route"> > > > > <from uri="direct:error-route"/> > > > > <transacted/> > > > > <process ref="errorProcessor"/> > > > > <to uri="jms:queue:JMS_TWO"/> > > > > </route> > > > > > > > > <route id="direct_dead_letter_channel"> > > > > <from uri="direct:dead_letter_channel"/> > > > > <process ref="deadChannelProcessor"/> > > > > <to uri="jms:queue:ERROR"/> > > > > </route> > > > > > > > > </camelContext> > > > > > > > > Thanks!!! > > > > > > > > > > > > -- > > > Claus Ibsen > > > ----------------- > > > http://davsclaus.com @davsclaus > > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >