ActiveMQ, Camel, RedeliveryDelay configuration is not used, immediate redlivery instead.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ, Camel, RedeliveryDelay configuration is not used, immediate redlivery instead.

eschorsch@proofpoint.com
Hello,

We are using a Camel/ActiveMQ/Spring configuration. We have setup a persistent queue backed by Kaha, and transactional configuration using org.springframwork.jms.connection.JmsTransactionManager.

We are trying to get the exception/re-delivery working correctly, and find that while the maximumRedeliveries configuration is honored, the redeliveryDelay is not. Rather, redelivery is executed immediately when the exceptioning consumer is finished executing it's rollback/close/synchronization logic.

Any input/experience would help...

The most confusing thing here, is that there redelivery count is honored, and running the code in the debugger we see the redeliveryDelay is set, and calculated correctly. There is even a scheduled task set to redeliver the message. However, as the infrastructure (ActiveMQMessageConsumer) is iterating through it's synchronizations during the rollback processing, a call to ActiveMQMessageConsumer.synchronization.afterRollback() results in an immediate redelivery of the message.


Below is our actual configuration.


Our JMS configuration:

   
    <bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="configuration">
            <bean class="org.apache.camel.component.jms.JmsConfiguration">
                <property name="transacted" value="true"/>
                <property name="transactionManager" ref="jmsTransactionManager"/>
                <property name="errorHandlerLogStackTrace" value="false"/>

               
                <property name="concurrentConsumers" value="${jms.concurrentConsumers:10}" />
                <property name="connectionFactory" ref="jmsConnectionFactory"/>
            </bean>
        </property>
    </bean>
    <bean id="jmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
        <property name="maxConnections" value="${jms.maxConnections:8}" />
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="tcp://${jms.host:localhost}:${jms.port:8791}" />
                <property name="redeliveryPolicyMap" ref="jmsRedeliveryPolicyMap" />
            </bean>
        </property>
        <property name="idleTimeout" value="0" />
    </bean>
    <amq:redeliveryPolicyMap id="jmsRedeliveryPolicyMap">
        <amq:redeliveryPolicyEntries>
            <bean class="org.apache.activemq.RedeliveryPolicy">
                <property name="queue" value="mailSender" />
                <property name="redeliveryDelay" value="#{ 1000 * ${mta.redeliveryDelay:300}}" />
                <property name="initialRedeliveryDelay" value="#{1000 * ${mta.redeliveryDelay:300}}" />
                <property name="maximumRedeliveryDelay" value="#{1000 * ${mta.redeliveryDelay:300}}" />
                <property name="maximumRedeliveries" value="${mta.maximumRedeliveries:3}" />
            </bean>
        </amq:redeliveryPolicyEntries>
        <amq:defaultEntry>
            <amq:redeliveryPolicy maximumRedeliveries="0" />
        </amq:defaultEntry>
    </amq:redeliveryPolicyMap>

our camel/consumer configuration:
       <camel:route id="mailSenderJMSConsumer">
            <camel:from uri="jms:queue:mailSender" />
            <camel:transacted/>

           
            <camel:onException redeliveryPolicyRef="emailSendFailurePolicy">
                <camel:exception>com.sendmail.reac.email.RetryableEmailException</camel:exception>
               
                <camel:handled>
                    <camel:constant>false</camel:constant>
                </camel:handled>
                <camel:log loggingLevel="WARN" message="${exception}" logName="com.sendmail.reac.camel"/>
            </camel:onException>

           
            <camel:onException redeliveryPolicyRef="emailSendFailurePolicy">
                <camel:exception>java.lang.Throwable</camel:exception>
               
                <camel:handled>
                    <camel:constant>true</camel:constant>
                </camel:handled>
                <camel:log loggingLevel="ERROR" message="${exception}" logName="com.sendmail.reac.camel"/>
            </camel:onException>

           
           <camel:to uri="bean:mailSender?method=createMimeMessageFromEmlString(${out.body})" />
           <camel:to uri="ref:emailEndpoint" />
       </camel:route>



thanks for any insight!
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ, Camel, RedeliveryDelay configuration is not used, immediate redlivery instead.

ceposta
Can you put together a small stand-alone unit test that can reproduce this
and I can take a look?


On Thu, Sep 26, 2013 at 1:19 PM, [hidden email] <
[hidden email]> wrote:

> Hello,
>
> We are using a Camel/ActiveMQ/Spring configuration. We have setup a
> persistent queue backed by Kaha, and transactional configuration using
> org.springframwork.jms.connection.JmsTransactionManager.
>
> We are trying to get the exception/re-delivery working correctly, and find
> that while the maximumRedeliveries configuration is honored, the
> redeliveryDelay is not. Rather, redelivery is executed immediately when the
> exceptioning consumer is finished executing it's
> rollback/close/synchronization logic.
>
> Any input/experience would help...
>
> The most confusing thing here, is that there redelivery count is honored,
> and running the code in the debugger we see the redeliveryDelay is set, and
> calculated correctly. There is even a scheduled task set to redeliver the
> message. However, as the infrastructure (ActiveMQMessageConsumer) is
> iterating through it's synchronizations during the rollback processing, a
> call to ActiveMQMessageConsumer.synchronization.afterRollback() results in
> an immediate redelivery of the message.
>
>
> /Below is our actual configuration./
>
>
> Our JMS configuration:
>
>
>     <bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property name="configuration">
>             <bean class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="transacted" value="true"/>
>                 <property name="transactionManager"
> ref="jmsTransactionManager"/>
>                 <property name="errorHandlerLogStackTrace" value="false"/>
>
>
>                 <property name="concurrentConsumers"
> value="${jms.concurrentConsumers:10}" />
>                 <property name="connectionFactory"
> ref="jmsConnectionFactory"/>
>             </bean>
>         </property>
>     </bean>
>     <bean id="jmsConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> init-method="start"
> destroy-method="stop">
>         <property name="maxConnections" value="${jms.maxConnections:8}" />
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL"
> value="tcp://${jms.host:localhost}:${jms.port:8791}" />
>                 <property name="redeliveryPolicyMap"
> ref="jmsRedeliveryPolicyMap" />
>             </bean>
>         </property>
>         <property name="idleTimeout" value="0" />
>     </bean>
>     <amq:redeliveryPolicyMap id="jmsRedeliveryPolicyMap">
>         <amq:redeliveryPolicyEntries>
>             <bean class="org.apache.activemq.RedeliveryPolicy">
>                 <property name="queue" value="mailSender" />
>                 <property name="redeliveryDelay" value="#{ 1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="initialRedeliveryDelay" value="#{1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="maximumRedeliveryDelay" value="#{1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="maximumRedeliveries"
> value="${mta.maximumRedeliveries:3}" />
>             </bean>
>         </amq:redeliveryPolicyEntries>
>         <amq:defaultEntry>
>             <amq:redeliveryPolicy maximumRedeliveries="0" />
>         </amq:defaultEntry>
>     </amq:redeliveryPolicyMap>
>
> our camel/consumer configuration:
>        <camel:route id="mailSenderJMSConsumer">
>             <camel:from uri="jms:queue:mailSender" />
>             <camel:transacted/>
>
>
>             <camel:onException
> redeliveryPolicyRef="emailSendFailurePolicy">
>
>
> <camel:exception>com.sendmail.reac.email.RetryableEmailException</camel:exception>
>
>                 <camel:handled>
>                     <camel:constant>false</camel:constant>
>                 </camel:handled>
>                 <camel:log loggingLevel="WARN" message="${exception}"
> logName="com.sendmail.reac.camel"/>
>             </camel:onException>
>
>
>             <camel:onException
> redeliveryPolicyRef="emailSendFailurePolicy">
>                 <camel:exception>java.lang.Throwable</camel:exception>
>
>                 <camel:handled>
>                     <camel:constant>true</camel:constant>
>                 </camel:handled>
>                 <camel:log loggingLevel="ERROR" message="${exception}"
> logName="com.sendmail.reac.camel"/>
>             </camel:onException>
>
>
>            <camel:to
> uri="bean:mailSender?method=createMimeMessageFromEmlString(${out.body})" />
>            <camel:to uri="ref:emailEndpoint" />
>        </camel:route>
>
>
>
> thanks for any insight!
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-Camel-RedeliveryDelay-configuration-is-not-used-immediate-redlivery-instead-tp4671869.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ, Camel, RedeliveryDelay configuration is not used, immediate redlivery instead.

gtully
In reply to this post by eschorsch@proofpoint.com
check the cache level. The consumer (where amq does redelivery) is
probably closed after each receipt, so the broker just does a
redispatch to one of the other available consumers.
The broker redelivery plugin can help but the root cause is session
level transaction enlistment which is done on session create.

On 26 September 2013 21:19, [hidden email]
<[hidden email]> wrote:

> Hello,
>
> We are using a Camel/ActiveMQ/Spring configuration. We have setup a
> persistent queue backed by Kaha, and transactional configuration using
> org.springframwork.jms.connection.JmsTransactionManager.
>
> We are trying to get the exception/re-delivery working correctly, and find
> that while the maximumRedeliveries configuration is honored, the
> redeliveryDelay is not. Rather, redelivery is executed immediately when the
> exceptioning consumer is finished executing it's
> rollback/close/synchronization logic.
>
> Any input/experience would help...
>
> The most confusing thing here, is that there redelivery count is honored,
> and running the code in the debugger we see the redeliveryDelay is set, and
> calculated correctly. There is even a scheduled task set to redeliver the
> message. However, as the infrastructure (ActiveMQMessageConsumer) is
> iterating through it's synchronizations during the rollback processing, a
> call to ActiveMQMessageConsumer.synchronization.afterRollback() results in
> an immediate redelivery of the message.
>
>
> /Below is our actual configuration./
>
>
> Our JMS configuration:
>
>
>     <bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property name="configuration">
>             <bean class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="transacted" value="true"/>
>                 <property name="transactionManager"
> ref="jmsTransactionManager"/>
>                 <property name="errorHandlerLogStackTrace" value="false"/>
>
>
>                 <property name="concurrentConsumers"
> value="${jms.concurrentConsumers:10}" />
>                 <property name="connectionFactory"
> ref="jmsConnectionFactory"/>
>             </bean>
>         </property>
>     </bean>
>     <bean id="jmsConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start"
> destroy-method="stop">
>         <property name="maxConnections" value="${jms.maxConnections:8}" />
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL"
> value="tcp://${jms.host:localhost}:${jms.port:8791}" />
>                 <property name="redeliveryPolicyMap"
> ref="jmsRedeliveryPolicyMap" />
>             </bean>
>         </property>
>         <property name="idleTimeout" value="0" />
>     </bean>
>     <amq:redeliveryPolicyMap id="jmsRedeliveryPolicyMap">
>         <amq:redeliveryPolicyEntries>
>             <bean class="org.apache.activemq.RedeliveryPolicy">
>                 <property name="queue" value="mailSender" />
>                 <property name="redeliveryDelay" value="#{ 1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="initialRedeliveryDelay" value="#{1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="maximumRedeliveryDelay" value="#{1000 *
> ${mta.redeliveryDelay:300}}" />
>                 <property name="maximumRedeliveries"
> value="${mta.maximumRedeliveries:3}" />
>             </bean>
>         </amq:redeliveryPolicyEntries>
>         <amq:defaultEntry>
>             <amq:redeliveryPolicy maximumRedeliveries="0" />
>         </amq:defaultEntry>
>     </amq:redeliveryPolicyMap>
>
> our camel/consumer configuration:
>        <camel:route id="mailSenderJMSConsumer">
>             <camel:from uri="jms:queue:mailSender" />
>             <camel:transacted/>
>
>
>             <camel:onException redeliveryPolicyRef="emailSendFailurePolicy">
>
> <camel:exception>com.sendmail.reac.email.RetryableEmailException</camel:exception>
>
>                 <camel:handled>
>                     <camel:constant>false</camel:constant>
>                 </camel:handled>
>                 <camel:log loggingLevel="WARN" message="${exception}"
> logName="com.sendmail.reac.camel"/>
>             </camel:onException>
>
>
>             <camel:onException redeliveryPolicyRef="emailSendFailurePolicy">
>                 <camel:exception>java.lang.Throwable</camel:exception>
>
>                 <camel:handled>
>                     <camel:constant>true</camel:constant>
>                 </camel:handled>
>                 <camel:log loggingLevel="ERROR" message="${exception}"
> logName="com.sendmail.reac.camel"/>
>             </camel:onException>
>
>
>            <camel:to
> uri="bean:mailSender?method=createMimeMessageFromEmlString(${out.body})" />
>            <camel:to uri="ref:emailEndpoint" />
>        </camel:route>
>
>
>
> thanks for any insight!
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Camel-RedeliveryDelay-configuration-is-not-used-immediate-redlivery-instead-tp4671869.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



--
http://redhat.com
http://blog.garytully.com
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ, Camel, RedeliveryDelay configuration is not used, immediate redlivery instead.

eschorsch@proofpoint.com
gtully,

Setting cacheLevelName=CACHE_CONSUMER solved the issue, thanks!