|
|
|
I have tried with a jms example and it works in the unit tests in the source code.
Are you sure you have Camel 1.4-SNAPSHOT in ActiveMQ where you run your project? Hi Claus.
Meanwhile I've realized that the problem is a misunderstanding on my side what camel is supposed to do. Sorry for mixing things up. Thanks for you help. Regards, Hi.
Sorry for reopening but the redeliveryDelay problem still exists. But it seems no camel problem then because I'm not using camel anymore, instead the redeliveryPolicy on the AQConnectionFactory. So, should that be moved to the AQM project then? There I'm using AMQ 5.1.0 (Camel 1.3). Hi Veit
Yes please open a ticket on the ActiveMQ project if its solely an ActiveMQ problem. Veit. I managed to move the issue from Camel to ActiveMQ project.
Veit. Can you add your new configuration etc. for the ActiveMQ that demonstrates the problem? I am sure the ActiveMQ comitters want to see your configuration file and what the problem is you have.
Thanks Claus.
Sure, here's my applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <!-- ActiveMQ destinations to use --> <bean id="jmsFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <!-- Spring JMS Template --> <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <!-- and this is the message listener container --> </beans> The messageListener will create a RuntimeException on the onMessage method to produce an error. The first redelivery attempt occurs immediately, without respect to the initialRedeliveryDelay. Redelivery policy doesn't work with Spring's org.springframework.jms.listener.DefaultMessageListenerContainer at all
That happens, because DefaultMessageListenerContainer closes the consumer, session and connection, and do the reconnect if message listener throws exception, and of course previous delivery timepoint is empty in the new consumer. It happens, because DefaultMessageListenerContainer doesn't know what a cause of JMSException. Maybe it was disconnection... and ConnectionFactory haven't reconnection logic... I wrote my own simple MessageListenerContainer, that doesn't do reconnection if JMSException is thrown, because ActiveMQConnectionFactory has reconnection logic I'm sorry to correct you, but it IS working with the above configuration. All parameters I change within the redeliveryPolicy bean definition affecting the redelivery within the sping bean! The only thing that doesn't work correctly (or needs enhancement) is the initial redelivery.
I don't know how do you reach that, but if I use DefaultMessageListenerContainer all redeliveries happens immediately, not first only.
If any Execption in MessageListener happens it always closes the connnection DefaultMessageListenerContainer.java private class AsyncMessageListenerInvoker implements SchedulingAwareRunnable { .... catch (Throwable ex) { clearResources(); ... } ... } private void clearResources() { if (sharedConnectionEnabled()) { synchronized (sharedConnectionMonitor) { JmsUtils.closeMessageConsumer(this.consumer); JmsUtils.closeSession(this.session); } } else { JmsUtils.closeMessageConsumer(this.consumer); JmsUtils.closeSession(this.session); } this.consumer = null; this.session = null; } @Dima:
Now, I can confirm your findings! After I set the jmsTransactionManager in my config (not just sessionTransacted=true like before) I encounter immediate redelivery without delay/backoffs, too: <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> After I set this, the MesageListener also checks connections actively - which is very noisy. So in the end: is this all expected behavior? I'm a bit confused... |
||||||||||||||||||||||||||||||||||||||||||||||||||||
[ main] RedeliveryPolicy DEBUG Sleeping for: 30000 millis until attempting redelivery
And then on the 2nd
[ main] RedeliveryPolicy DEBUG Sleeping for: 60000 millis until attempting redelivery
Your route doesn't do anything with the received message from activemq:NEW. How do you actually trigger the failure and the redelivery?