You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Michele <mi...@finconsgroup.com> on 2015/11/06 07:47:20 UTC

Redelivery Policy set on Camel is ignored

Hi,

I'm enabling transaction in JMS Queue consuming route, and trying to
configure RedeliveryPolicy in Spring/Camel file as you can see below:

<bean id="myRedeliveryPolicyConfig"
class="org.apache.camel.processor.RedeliveryPolicy">
     <property name="maximumRedeliveries" value="3"/>
     <property name="redeliveryDelay" value="60000"/>
     <property name="retryAttemptedLogLevel" value="WARN" />
  </bean>
  <bean id="exceptionHandler"
class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
  <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig" />
    </bean>
 
  <camelContext id="ActiveMQContext"
xmlns="http://camel.apache.org/schema/spring">
  <route id="FileToJMS">
  <from uri="file:${uriToFile}" />
  <to uri="activemq:queue:incomingTickets" />
  </route>
 
  <route errorHandlerRef="exceptionHandler" id="normalize-message-data">
  <from uri="activemq:incomingTickets" />
  <transacted />
  <log message="Received: ${body}" />
  <rollback />

     <to uri="mock:result" />
  </route>
  </camelContext>
 
I invoke rollback to check if messages are redelivered to a client.
But redelivery policy configuration is ignored because all redeliveries are
immediate (Underline log warn)

*First attempt*
*12:37:23,471 | WARN  | incomingTickets] | TransactionErrorHandler    *     
| 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Transaction
rollback (0x64f41c09) redelivered(false) for (MessageId:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-3) caught:
org.apache.camel.RollbackExchangeException: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
12:37:23,471 | WARN  | incomingTickets] | EndpointMessageListener          |
198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Execution of JMS
message listener failed. Caused by: [org.apache.camel.RuntimeCamelException
- org.apache.camel.RollbackExchangeException: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]]
12:37:23,511 | INFO  | incomingTickets] | normalize-message-data           |
198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Received: Azienda
7 by Rest API,example4@example.com
12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler          |
203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
(MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-4) due: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler          |
203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
(MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-4) due: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]

*Second attempt*
*12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler*         
| 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Transaction
rollback (0x64f41c09) redelivered(true) for (MessageId:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-4) caught:
org.apache.camel.RollbackExchangeException: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
12:37:23,521 | WARN  | incomingTickets] | EndpointMessageListener          |
198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Execution of JMS
message listener failed. Caused by: [org.apache.camel.RuntimeCamelException
- org.apache.camel.RollbackExchangeException: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]]
12:37:23,581 | INFO  | incomingTickets] | normalize-message-data           |
198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Received: Azienda
7 by Rest API,example4@example.com
12:37:23,581 | WARN  | incomingTickets] | TransactionErrorHandler          |
203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
(MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-5) due: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
12:37:23,581 | WARN  | incomingTickets] | TransactionErrorHandler          |
203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
(MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
ID-FGBAL201530-51470-1446720230674-5-5) due: Intended rollback.
Exchange[JmsMessage[JmsMessageID:
ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
 
and so on.
What do I do to achieve a redelivery with interval of one minute and max
redeliveries 3? I wrong a configuration?
 
Environment:
JBoss Fuse 6.2 on Java 1.8
 
Thank you in advance
 
Regards
Michele



--
View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Redelivery Policy set on Camel is ignored

Posted by Michele <mi...@finconsgroup.com>.
Hi Claus,

i cleaned my test-project and i re-configured it in this way and it seems
work fine :):
Redelivery policy is respected and after 3 attempts message is moved in
ActiveMQ.DLQ.

<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="brokerURL"
value="tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=3&amp;jms.redeliveryPolicy.redeliveryDelay=60000"
/>
		<property name="userName" value="admin" />
		<property name="password" value="admin" />
	</bean>
	
	<bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
		init-method="start" destroy-method="stop">
		<property name="maxConnections" value="8" />
		<property name="connectionFactory" ref="jmsConnectionFactory" />
	</bean>
	
	<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
		<property name="connectionFactory" ref="pooledConnectionFactory" />
		<property name="concurrentConsumers" value="10" />
		
		<property name="transacted" value="true" />
		
		<property name="transactionManager" ref="txManager" />
		
		
		<property name="cacheLevelName" value="CACHE_CONSUMER" />
		<property name="transferExchange" value="true" />
	</bean>
	
	
	<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
		<property name="configuration" ref="jmsConfig" />
	</bean>

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

Thank you very much for your tips. 

Best regards

Michele



--
View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409p5773536.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Redelivery Policy set on Camel is ignored

Posted by Michele <mi...@finconsgroup.com>.
Hi Claus,

I tried to set redelivery policy on the ActiveMQ Broker as you suggested and
i modified my configuration as:

<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name=&quot;brokerURL&quot;
value=&quot;tcp://localhost:61616?&lt;b>jms.redeliveryPolicy.maximumRedeliveries=3&amp;jms.redeliveryPolicy.redeliveryDelay=60000&amp;jms.redeliveryPolicy.initialRedeliveryDelay=0*"
/>
		<property name="userName" value="admin" />
		<property name="password" value="admin" />

</bean>

and i also tried to set it by setting redelivery policy property defined as

 	<bean id="RedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
 		<property name="maximumRedeliveries" value="3" /> 
 		<property name="initialRedeliveryDelay" value="0" />
 		<property name="redeliveryDelay" value="60000" /> 
	</bean>

but the policy is ignored, redeliveries are immediate.

I am a bit 'confused. 

Sorry.

Thanks in advance.

Kind greeting

Michele






--
View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409p5773525.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Redelivery Policy set on Camel is ignored

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah you need to set the redelivery on the ActiveMQ brokerUrl as its
baked into AMQ redelivery.
I was quick reading the mails on this user forum and didnt spot your
code was the Camel AMQ redelivery class.

As you want to use TX and rollback on failure and let the AMQ broker
redeliver the message.

The Camel redelivery policy is when Camel is orchestrating the
redelivery, which is not the case when you want to use JMS TX.

There is an example here
https://github.com/camelinaction/camelinaction2/blob/master/chapter12/riderautoparts-partner/src/test/resources/camelinaction/RiderAutoPartsPartnerTransactedTest.xml

Though it uses the default redelivery options from AMQ. You can
configure those in the brokerUrl, see bottom of this page
http://activemq.apache.org/connection-configuration-uri.html

And to make confusion even bigger, then there is a AMQ broker
redelivery functionality also but its using the AMQ scheduler which is
not supported in all AMQ datastores. Both kinds have their pros/cons.





On Fri, Nov 6, 2015 at 11:35 AM, Michele
<mi...@finconsgroup.com> wrote:
> Hi Claus,
>
> first of all thank you very much:).
>
> I read and followed the link that you suggested and i changed the
> configuration as you can see below:
>
> <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>                 <property name="connectionFactory" ref="pooledConnectionFactory" />
>                 <property name="transactionManager" ref="jmsTransactionManager" />
>                 <property name="concurrentConsumers" value="10" />
>                 <property name="transferExchange" value="true" />
>
>                 <property name="transacted" value="true" />
>                 <property name="lazyCreateTransactionManager" value="false" />
>                 *<property name="cacheLevelName" value="CACHE_CONSUMER" />*
>                 <property name="forceSendOriginalMessage" value="true" />
> </bean>
> But the result is the same. Redelivery Policy is ignored.
> I need to configure a DMLC for caching messages to re-delivery?
>
> Thanks in advance.
>
> Greeting
> Michele
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409p5773433.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Redelivery Policy set on Camel is ignored

Posted by Michele <mi...@finconsgroup.com>.
Hi Claus,

first of all thank you very much:).

I read and followed the link that you suggested and i changed the
configuration as you can see below:

<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
		<property name="connectionFactory" ref="pooledConnectionFactory" />
		<property name="transactionManager" ref="jmsTransactionManager" />
		<property name="concurrentConsumers" value="10" />
		<property name="transferExchange" value="true" />
		
		<property name="transacted" value="true" />
		<property name="lazyCreateTransactionManager" value="false" />
		*<property name="cacheLevelName" value="CACHE_CONSUMER" />*
		<property name="forceSendOriginalMessage" value="true" />		
</bean>
But the result is the same. Redelivery Policy is ignored.
I need to configure a DMLC for caching messages to re-delivery?

Thanks in advance.

Greeting
Michele
  



--
View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409p5773433.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Redelivery Policy set on Camel is ignored

Posted by Claus Ibsen <cl...@gmail.com>.
Are you using cache consumer on the jms component.

You would need that as the redelivery delay is tracked on the client
side, and it needs to cache the consumer so its the same consumer
doing the redelivery.

See the cache level option at
http://camel.apache.org/jms

On Fri, Nov 6, 2015 at 7:47 AM, Michele
<mi...@finconsgroup.com> wrote:
> Hi,
>
> I'm enabling transaction in JMS Queue consuming route, and trying to
> configure RedeliveryPolicy in Spring/Camel file as you can see below:
>
> <bean id="myRedeliveryPolicyConfig"
> class="org.apache.camel.processor.RedeliveryPolicy">
>      <property name="maximumRedeliveries" value="3"/>
>      <property name="redeliveryDelay" value="60000"/>
>      <property name="retryAttemptedLogLevel" value="WARN" />
>   </bean>
>   <bean id="exceptionHandler"
> class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
>   <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig" />
>     </bean>
>
>   <camelContext id="ActiveMQContext"
> xmlns="http://camel.apache.org/schema/spring">
>   <route id="FileToJMS">
>   <from uri="file:${uriToFile}" />
>   <to uri="activemq:queue:incomingTickets" />
>   </route>
>
>   <route errorHandlerRef="exceptionHandler" id="normalize-message-data">
>   <from uri="activemq:incomingTickets" />
>   <transacted />
>   <log message="Received: ${body}" />
>   <rollback />
>
>      <to uri="mock:result" />
>   </route>
>   </camelContext>
>
> I invoke rollback to check if messages are redelivered to a client.
> But redelivery policy configuration is ignored because all redeliveries are
> immediate (Underline log warn)
>
> *First attempt*
> *12:37:23,471 | WARN  | incomingTickets] | TransactionErrorHandler    *
> | 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Transaction
> rollback (0x64f41c09) redelivered(false) for (MessageId:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-3) caught:
> org.apache.camel.RollbackExchangeException: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
> 12:37:23,471 | WARN  | incomingTickets] | EndpointMessageListener          |
> 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Execution of JMS
> message listener failed. Caused by: [org.apache.camel.RuntimeCamelException
> - org.apache.camel.RollbackExchangeException: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]]
> 12:37:23,511 | INFO  | incomingTickets] | normalize-message-data           |
> 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Received: Azienda
> 7 by Rest API,example4@example.com
> 12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler          |
> 203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
> (MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-4) due: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
> 12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler          |
> 203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
> (MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-4) due: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
>
> *Second attempt*
> *12:37:23,521 | WARN  | incomingTickets] | TransactionErrorHandler*
> | 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Transaction
> rollback (0x64f41c09) redelivered(true) for (MessageId:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-4) caught:
> org.apache.camel.RollbackExchangeException: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
> 12:37:23,521 | WARN  | incomingTickets] | EndpointMessageListener          |
> 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Execution of JMS
> message listener failed. Caused by: [org.apache.camel.RuntimeCamelException
> - org.apache.camel.RollbackExchangeException: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]]
> 12:37:23,581 | INFO  | incomingTickets] | normalize-message-data           |
> 198 - org.apache.camel.camel-core - 2.15.1.redhat-620133 | Received: Azienda
> 7 by Rest API,example4@example.com
> 12:37:23,581 | WARN  | incomingTickets] | TransactionErrorHandler          |
> 203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
> (MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-5) due: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
> 12:37:23,581 | WARN  | incomingTickets] | TransactionErrorHandler          |
> 203 - org.apache.camel.camel-spring - 2.15.1.redhat-620133 | Rollback
> (MessageId: ID:FGBAL201530-51469-1446720227638-11:4:3:1:1 on ExchangeId:
> ID-FGBAL201530-51470-1446720230674-5-5) due: Intended rollback.
> Exchange[JmsMessage[JmsMessageID:
> ID:FGBAL201530-51469-1446720227638-11:4:3:1:1]]
>
> and so on.
> What do I do to achieve a redelivery with interval of one minute and max
> redeliveries 3? I wrong a configuration?
>
> Environment:
> JBoss Fuse 6.2 on Java 1.8
>
> Thank you in advance
>
> Regards
> Michele
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Redelivery-Policy-set-on-Camel-is-ignored-tp5773409.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2