0
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

hars
  • 127
  • 4
  • 17

2 Answers2

2

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).

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • Can you add to the existing configuration. I dont really use xml configuration. I use Java based configuration. I want the messages to be discarded after retries rather than go to DLQ. – hars Nov 10 '17 at 15:28
  • Is it possible to discard only a certain messages with a pattern by configuring in activemq.xml ? – Pathfinder Mar 17 '23 at 00:42
  • @Pathfinder nah, for that you probably need to use the broker Camel component, https://activemq.apache.org/broker-camel-component. It's VERY powerful though so you should be able to do whatever you need. – Petter Nordlander Mar 17 '23 at 09:27
1

You can use:

RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
redeliveryPolicy.setMaximumRedeliveries(-1);
Mika Sundland
  • 18,120
  • 16
  • 38
  • 50
TABHSA
  • 9
  • 1