In this piece of code I'm trying to set up a redelivery police only only for the messages in a specific topic:
RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
emailByFolioRedeliveryPolicy.setInitialRedeliveryDelay(5000);
emailByFolioRedeliveryPolicy.setRedeliveryDelay(5000);
emailByFolioRedeliveryPolicy.setUseExponentialBackOff(false);
emailByFolioRedeliveryPolicy.setBackOffMultiplier(10);
emailByFolioRedeliveryPolicy.setMaximumRedeliveries(3);
PooledConnectionFactory connPool = new PooledConnectionFactory();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
RedeliveryPolicyMap redeliveryPolicyMap = connectionFactory.getRedeliveryPolicyMap();
redeliveryPolicyMap.put(new ActiveMQTopic("VirtualTopic.firstTopic"), redeliveryPolicy );
connPool.setConnectionFactory(connectionFactory);
connPool.setCreateConnectionOnStartup(true);
connPool.setMaxConnections(20);
return connPool;
The problem is that the messages being sent to another topic (VirtualTopic.secondTopic) are also impacted for this policy, because I can see the listener on the second topic is processing redelivered messages. In the RedeliveryPolicyMap I'm adding the policy specifying the Destination. But for some reason I can not get it working as expected.
The expected is:
- A new message A is posted to "VirtualTopic.firstTopic"
- A new message B is posted to "VirtualTopic.secondTopic"
- The listener "Consume.FIRST.VirtualTopic.firstTopic" on "VirtualTopic.firstTopic" will process the message A.
- The listener "Consume.SECOND.VirtualTopic.firstTopic" on "VirtualTopic.secondTopic" will process the message B.
- If the FIRST listener fails, will retry in 15 minutes.
- If the SECOND listener fails, nothing happens. The message will end up in the Dead Letter Queue.
I took the configuration from this page:
http://activemq.apache.org/redelivery-policy.html
Does anybody has accomplished something like this? Thanks.