You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Felix Thomas <fe...@gmail.com> on 2015/11/19 15:52:41 UTC

Transacted Mode Not working as expected Camel spring JMS

hello,

     I am not sure if I have implemented it correctly. I have the below
route definition . But in case of exception in DeadLetterChannel the
messages are acknowledged  and removed from the queue. If I dont configure
the deadletterchannel route  then the ActiveMQ moves the messages to its
DLQ queue which is fine.  But incase for any reason the rabbitMQ mentioned
in the Deadletterchannel goes down , the messages are not re directed to
the activeMQ DLQ but gets lost somewhere.   How do I avoid this situation .
Incase of any exception or failure of any endpoint in the deadletterchannel
the messages should not be acknowledged in the source .

My beans Entry

   <bean id="jmsConnectionFactory"
               class="org.apache.activemq.ActiveMQConnectionFactory">
               <property name="brokerURL" value="tcp://localhost:61616" />
    </bean>

    <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
            <property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>


  <bean id="activemq"
        class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
        <property name="transactionManager" ref="jmsTransactionManager"/>
    </bean>
    <bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <property name="transactionManager" ref="jmsTransactionManager"/>
        <property name="propagationBehaviorName"
value="PROPAGATION_REQUIRED"/>
    </bean>

    <bean id="CustomErrorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
        <property name="deadLetterUri"
value="direct:CustomDeadErrorQueueRoute" />
        <property name="redeliveryPolicy"
ref="CustomRedeliveryPolicyConfig" />
        <property name="useOriginalMessage" value="true" />
    </bean>

    <bean id="CustomRedeliveryPolicyConfig"
class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="1" />
        <property name="redeliveryDelay" value="5000" />
        <property name="allowRedeliveryWhileStopping" value="false" />
    </bean>

My Route Defined.


<route customId="false" id="routeACtiveMQ"
errorHandlerRef="CustomErrorHandler" xmlns="
http://camel.apache.org/schema/spring">
            <from
uri="activemq:NEWQUEUE?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50&amp;transferException=true&amp;acknowledgementModeName=CLIENT_ACKNOWLEDGE&amp;requestTimeout=5000"/>
            <transacted/>
               <setHeader headerName="DATASOURCEID">
              <simple resultType="java.lang.Integer">8</simple>
            </setHeader>
            <process ref="CustomMappingJSON" id="process2"/>
            <multicast parallelProcessing="true"
executorServiceRef="customThreadPoolProfile" id="multicast2">
                <pipeline id="pipeline1">
                    <marshal id="marshal1">
                        <custom ref="kyroFormat"/>
                    </marshal>
                    <to
uri="rabbitmq://localhost/HDFSMASTER?autoDelete=false&amp;queue=HDFSMASTERQUEUE&amp;username=guest&amp;password=guest&amp;routingKey=HDFSMASTER&amp;transferException=true&amp;autoAck=false"
id="to9"/>
                </pipeline>
            </multicast>
      </route>


        <route  customId="false" id="CustomDeadErrorQueueRoute"
            xmlns="http://camel.apache.org/schema/spring">
            <from uri="direct:CustomDeadErrorQueueRoute" />
            <to
uri="rabbitmq://localhost/RULESERROR?autoDelete=false&amp;queue=RULESERRORQUEUE&amp;username=guest&amp;password=guest&amp;routingKey=RULESERROR&amp;transferException=true&amp;autoAck=false"
/>
        </route>

Regards,
Fx