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:
I took the configuration from this page:
http://activemq.apache.org/redelivery-policy.html
Does anybody has accomplished something like this? Thanks.
答案 0 :(得分:0)
Policies are set at the ActiveMQConnectionFactory or ActiveMQConnection level - if your policies are different, you need to use different connection factories in your project accordingly. In the case you mentioned, you need to define 2 seperate ActiveMQ connection factories with their own redelivery policies. Hope it helps