I am using ActiveMQ 5.7.0 and trying to implement a redelivery policy. I have two queues that I need to set redelivery policies for. However in testing, it does not apply my policy. Instead of following the configuration below, it retries 7 times @ 1sec intervals (not what I specified).
<!-- ActiveMQ destinations to use -->
<amq:queue id="destinationOne" physicalName="${activemq.one.queuename}">
<amq:properties>
<amq:redeliveryPolicy destination="One.DLQ" maximumRedeliveries="5" initialRedeliveryDelay="300000" useExponentialBackOff="true" backOffMultiplier="2" maximumRedeliveryDelay="3600000"/>
</amq:properties>
</amq:queue>
<amq:queue id="destinationTwo" physicalName="${activemq.two.queuename}">
<amq:properties>
<amq:redeliveryPolicy destination="Two.DLQ" maximumRedeliveries="5" initialRedeliveryDelay="300000" useExponentialBackOff="true" backOffMultiplier="2" maximumRedeliveryDelay="3600000"/>
</amq:properties>
</amq:queue>
I have two listeners defined and they are applying the queues as below:
<bean id="oneMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destination" ref="destinationOne"/>
<property name="messageListener" ref="jmsOneListener" />
<property name="autoStartup" value="false" />
<property name="sessionTransacted" value="true"/>
<property name="concurrentConsumers" value="2" />
</bean>
<bean id="twoMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destination" ref="destinationTwo"/>
<property name="messageListener" ref="jmsTwoListener" />
<property name="autoStartup" value="false" />
<property name="sessionTransacted" value="true"/>
<property name="concurrentConsumers" value="2" />
</bean>
I agree with Tim’s answer: policies are defined on the underlying connection factory object. For your scenario, I think you’d need to define 2 seperate ActiveMQ connection factories with there own policy, then define a seperate Spring connection factory for each which is then used appropriately
Here’s an example I’ve used on ActiveMQ v5.5 before: