0
votes
private BrokerService createBroker() throws IOException, Exception {
         BrokerService broker = new BrokerService();KahaDBStore kaha=new KahaDBStore();
         File file =new File(path);
         TransportConnector connector = new TransportConnector();
         connector.setUri(new URI(DEFAULT_BROKER_URL));
         kaha.setDirectory(file);
         broker.addConnector(connector);
         broker.setPersistenceAdapter(kaha);
}

This is configuration for my broker. Can somebody specify the configuration, how I can stop messages from going to DLQ after my re-delivery policy?

Note : I have already visited this, http://activemq.apache.org/message-redelivery-and-dlq-handling.html

2

2 Answers

2
votes

The question is - what do you want to do with them instead?

Just drop them after all redelivery attempts has been exhausted?

Configure the discard plugin

<deadLetterStrategy>
   <discarding/>
</deadLetterStrategy>

or by Java

PolicyEntry policy = new PolicyEntry();
policy.setDeadLetterStrategy(new DiscardingDeadLetterStrategy());
PolicyMap policyMap = new PolicyMap();
policyMap.setDefaultEntry(policy);
broker.setDestinationPolicy(policyMap);

Never exhaust redelivery and try until the message is through?

This may be problematic beacuse of poision messages - i.e. messages with corrupt payload that never can be processed and has to be removed to not interrupt the flow. If you want this anyway, configure a client side maximumRedelivery to -1 (see docs).

1
votes

You can use:

RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
redeliveryPolicy.setMaximumRedeliveries(-1);