You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dainiu5m3 <da...@gmail.com> on 2014/10/28 17:23:38 UTC

RedeliveryPolicy is ignored by ActiveMQ in Camel route configuration

Hi,

I'm enabling transaction in JMS Queue consuming route, and trying to
configure RedeliveryPolicy in Spring/Camel file, but for some reason
redelivery policy is ignored, and JMS redelivery happens 6 times, and
immediately. What I want to achieve is 3 deliveries, with interval of 2 sec
between each other.
Environment:
  Java 1.8, compiled for 1.7
  Camel 2.14.0
  ActiveMQ: 5.9.1, using Queue
  Spring: 4.0.7.RELEASE

Here are my configuration XML and Java route, maybe someone have idea what
I'm doing wrong?

======== XML Config ==================================
<beans xmlns="http://www.springframework.org/schema/beans"
       .................>

    <bean id="fromFileRoute" class="camelerrortest.routetx.FromFileRoute"/>
    <bean id="toQueueRoute" class="camelerrortest.routetx.ToQueueRoute"/>
    <bean id="persistenceRoute"
class="camelerrortest.routetx.PersistenceRoute"/>

    <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="transacted" value="true"/>
        <property name="transactionManager" ref="txManager"/>
    </bean>

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

    <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL"
value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=2"/>
        <property name="redeliveryPolicy">
            <bean class="org.apache.activemq.RedeliveryPolicy">
                <property name="maximumRedeliveries" value="3"/>
                <property name="redeliveryDelay" value="2000"/>
                <property name="maximumRedeliveryDelay" value="1000"/>
                <property name="initialRedeliveryDelay" value="1000"/>
            </bean>
        </property>
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <routeBuilder ref="fromFileRoute"/>
        <routeBuilder ref="toQueueRoute"/>
        <routeBuilder ref="persistenceRoute"/>
    </camelContext>

</beans>

====== Java Route =============================
public class PersistenceRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("activemq:incomingFiles?transacted=true")
                .transacted()
                .routeId("camel.imx.router.persistence")
                .bean(new ContentValidator())
                .to("file://C:/tmp/__camel_to_with_retry?autoCreate=false")
                .log(LoggingLevel.INFO, "Trying to persist payload from
body: ${body}");
    }
}

//Thanks in advance!





--
View this message in context: http://camel.465427.n5.nabble.com/RedeliveryPolicy-is-ignored-by-ActiveMQ-in-Camel-route-configuration-tp5758235.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RedeliveryPolicy is ignored by ActiveMQ in Camel route configuration

Posted by Minh Tran <da...@gmail.com>.
You can enable logging on the camel and activemq level to see who is doing the redelivery. You can even enable logging on the amq server side for more diagnostic info. From brief look at your code, your delay settings look weird. Your maximum delay is 1 second while your delivery delay is 2s. These are conflicting numbers. If you just want a constant delay, just set the redeliveryDelay property and leave everything else alone.

Personally I find the camel redelivery far more flexible and feature rich. I actually set my AMQ redelivery maximum to zero and configure redelivery exclusively in camel.

On 29/10/2014, at 9:14 AM, dainiu5m3 <da...@gmail.com> wrote:

> Minh Tran-2 wrote
>> It looks like you've configured redelivery in the activeMQ and not within
>> camel. This means camel isn't the one that is doing the redelivery,
>> activeMQ is. Is this what you wanted to do? 
> 
> Yes, that's right. I want to delegate redelivery task to JMS/AMQ, and
> actually it works, BUT it ignores the RedeliveryPolicy settings, and uses
> default ones; I not succeeded to find out why it ignores redelivery policy
> seetings. Maybe I'm missing some bit in configuration?..
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/RedeliveryPolicy-is-ignored-by-ActiveMQ-in-Camel-route-configuration-tp5758235p5758265.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: RedeliveryPolicy is ignored by ActiveMQ in Camel route configuration

Posted by dainiu5m3 <da...@gmail.com>.
Minh Tran-2 wrote
> It looks like you've configured redelivery in the activeMQ and not within
> camel. This means camel isn't the one that is doing the redelivery,
> activeMQ is. Is this what you wanted to do? 

Yes, that's right. I want to delegate redelivery task to JMS/AMQ, and
actually it works, BUT it ignores the RedeliveryPolicy settings, and uses
default ones; I not succeeded to find out why it ignores redelivery policy
seetings. Maybe I'm missing some bit in configuration?..



--
View this message in context: http://camel.465427.n5.nabble.com/RedeliveryPolicy-is-ignored-by-ActiveMQ-in-Camel-route-configuration-tp5758235p5758265.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RedeliveryPolicy is ignored by ActiveMQ in Camel route configuration

Posted by Minh Tran <da...@gmail.com>.
It looks like you've configured redelivery in the activeMQ and not within camel. This means camel isn't the one that is doing the redelivery, activeMQ is. Is this what you wanted to do? 

On 29/10/2014, at 3:23 AM, dainiu5m3 <da...@gmail.com> wrote:

> Hi,
> 
> I'm enabling transaction in JMS Queue consuming route, and trying to
> configure RedeliveryPolicy in Spring/Camel file, but for some reason
> redelivery policy is ignored, and JMS redelivery happens 6 times, and
> immediately. What I want to achieve is 3 deliveries, with interval of 2 sec
> between each other.
> Environment:
>  Java 1.8, compiled for 1.7
>  Camel 2.14.0
>  ActiveMQ: 5.9.1, using Queue
>  Spring: 4.0.7.RELEASE
> 
> Here are my configuration XML and Java route, maybe someone have idea what
> I'm doing wrong?
> 
> ======== XML Config ==================================
> <beans xmlns="http://www.springframework.org/schema/beans"
>       .................>
> 
>    <bean id="fromFileRoute" class="camelerrortest.routetx.FromFileRoute"/>
>    <bean id="toQueueRoute" class="camelerrortest.routetx.ToQueueRoute"/>
>    <bean id="persistenceRoute"
> class="camelerrortest.routetx.PersistenceRoute"/>
> 
>    <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>        <property name="transacted" value="true"/>
>        <property name="transactionManager" ref="txManager"/>
>    </bean>
> 
>    <bean id="txManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>        <property name="connectionFactory" ref="jmsConnectionFactory"/>
>    </bean>
> 
>    <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>        <property name="brokerURL"
> value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=2"/>
>        <property name="redeliveryPolicy">
>            <bean class="org.apache.activemq.RedeliveryPolicy">
>                <property name="maximumRedeliveries" value="3"/>
>                <property name="redeliveryDelay" value="2000"/>
>                <property name="maximumRedeliveryDelay" value="1000"/>
>                <property name="initialRedeliveryDelay" value="1000"/>
>            </bean>
>        </property>
>    </bean>
> 
>    <camelContext xmlns="http://camel.apache.org/schema/spring">
>        <routeBuilder ref="fromFileRoute"/>
>        <routeBuilder ref="toQueueRoute"/>
>        <routeBuilder ref="persistenceRoute"/>
>    </camelContext>
> 
> </beans>
> 
> ====== Java Route =============================
> public class PersistenceRoute extends RouteBuilder {
>    @Override
>    public void configure() throws Exception {
>        from("activemq:incomingFiles?transacted=true")
>                .transacted()
>                .routeId("camel.imx.router.persistence")
>                .bean(new ContentValidator())
>                .to("file://C:/tmp/__camel_to_with_retry?autoCreate=false")
>                .log(LoggingLevel.INFO, "Trying to persist payload from
> body: ${body}");
>    }
> }
> 
> //Thanks in advance!
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/RedeliveryPolicy-is-ignored-by-ActiveMQ-in-Camel-route-configuration-tp5758235.html
> Sent from the Camel - Users mailing list archive at Nabble.com.