Question

Can we control the transaction retry interval in MDB? If so, please provide an example or direct me to the documentation. We want to set up a time interval of 3 min for MDB transactions. The desire is that if the query fails \first time, then it retries after 3 min of time has elapsed.

Was it helpful?

Solution

Vairam;

Take a look at the Hornet Documentation for Message Redelivery. The issues you need to consider are:

  • The redelivery delay (you indicated 3 minutes).
  • The number of times the message should be redelivered.
  • If you elect not to redeliver indefinitely, the final action that occurs when the last redelivery attempt fails which could be:
    • Drop the message.
    • Enqueue the message to the designated DLQ.
    • Enqueue the message to some other queue.

Setting the redelivery delay

Delayed redelivery is defined in the address-setting configuration.

Example:

 <!-- delay redelivery of messages for 3m -->
 <address-setting match="jms.queue.exampleQueue">
    <redelivery-delay>300000</redelivery-delay>
 </address-setting>

Setting the maximum number of redeliveries and DLQ configuration

This can be defined declaratively by specifying the DLQ configuration in the address-setting configuration:

Example:

 <!-- undelivered messages in exampleQueue will be sent to the dead letter address 
    deadLetterQueue after 3 unsuccessful delivery attempts
  -->
 <address-setting match="jms.queue.exampleQueue">
    <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>
    <max-delivery-attempts>3</max-delivery-attempts>
 </address-setting>

If you want to drop the message after the designated number of redelivery failures, check the message header value of "JMSXDeliveryCount" and if that number is equal to the maximum redeliveries, simply supress any exceptions and commit the transaction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top