activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From galix85 <jg...@vsn.es>
Subject Re: RedeliveryPolicy not working on ActiveMQ 5.6.0
Date Tue, 19 Jun 2012 17:08:14 GMT
Finally I find a solution of my problem.

In camel.xml you have to setup deliveryPolicy a twice, I don't know why but
for me works fine. 

The first of both is like a bean:

       <bean id="myRedeliveryPolicy"
class="org.apache.activemq.RedeliveryPolicy">
		<property name="initialRedeliveryDelay" value="5000" />
		<property name="redeliveryDelay" value="5000" />
		<property name="maximumRedeliveryDelay" value="10000" />
		<property name="maximumRedeliveries" value="2" />
		<property name="useExponentialBackOff" value="false" />
		<property name="backOffMultiplier" value="1" />
	</bean>

And second is like a errorHandler in each route you want to delivery the
message:

          <errorHandler id="delivery"><redeliveryPolicy
maximumRedeliveries="4" redeliveryDelay="5000"
retryAttemptedLogLevel="WARN"/></errorHandler>

              <route errorHandlerRef="delivery">
			<from uri="activemq:queue:foo"/>
			<transacted/>
			<setHeader headerName="Content-Type">
				<constant>application/xml</constant>
			</setHeader>
			<setHeader headerName="CamelHttpMethod">
				<constant>PUT</constant>
			</setHeader>
			<to uri="http://localhost:8080/webservice/"/>
		</route>

I did this way because "redeliveryDelay" of bean config didn't work well and
then I did the handleError.

The result is when message cannot delivery properly, Camel tries 2 times
(maximumRedeliveries of bean configuration) * (4 times (maximumRedeliveries
of errorHandler configuration) + 5000ms (redeliveryDelay of errorHandler
configuration)).

Complete Code:

 
<beans
   xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
  
  	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">

		<errorHandler id="delivery">
			<redeliveryPolicy maximumRedeliveries="4" redeliveryDelay="5000"
retryAttemptedLogLevel="WARN"/>
		</errorHandler>
	
                 <route errorHandlerRef="delivery">
			<from uri="activemq:queue:foo"/>
			<transacted/>
			<setHeader headerName="Content-Type">
				<constant>application/xml</constant>
			</setHeader>
			<setHeader headerName="CamelHttpMethod">
				<constant>PUT</constant>
			</setHeader>
			<to uri="http://localhost:8080/webservice/"/>
		</route>

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

	<bean id="myRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
		<property name="initialRedeliveryDelay" value="5000" />
		<property name="redeliveryDelay" value="5000" />
		<property name="maximumRedeliveryDelay" value="10000" />
		<property name="maximumRedeliveries" value="2" />
		<property name="useExponentialBackOff" value="false" />
		<property name="backOffMultiplier" value="1" />
	</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="transacted" value="true"/>
	</bean>
</beans>

I hope I can help someone with the same issue.

Cheers.





--
View this message in context: http://activemq.2283324.n4.nabble.com/RedeliveryPolicy-not-working-on-ActiveMQ-5-6-0-tp4653355p4653380.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message