Handling retries and quarantine

So I have a basic sample with events being published over an AMQP event bus. In my setup, I have a very basic direct exchange - single queue with multiple listener processes all listening on the same queue.

In case a worker dies while processing a message, it should be requeued back and picked up by the next available listener. If say there’s something bad about the message, then the message should at max be retried for 4 times. After the 4th time, the message should be quarantined (maybe put on a dead letter queue).

For the first one above, I guess an explicit AMQP ack is required. Is there an example of configuring this on Axon amqp?

For the second requirement (fixed number of retries): I’m pretty new to AMQP as well - but looking at AMQP, it doesn’t offer anything around a dequeue count. Direction (from SO) seems to be to add a message header to indicate number of dequeues. Again, what’s a good extension point in Axon for this? Examples would be great :slight_smile:

On the Axon side, I see error handling section under event processing (http://www.axonframework.org/docs/2.3/event-processing.html) - but this just indicates that the event handler is retried after a delay (on the same node in case of a transient exception from the event handler)


Hi Raghu,

you can configure Spring to handle events from the queue in a transaction. When the transaction fails, it puts the message on the queue again. I believe messages get a “resend” flag of some sort when this happens. In your cluster configuration, provide a (Spring) transaction manager to make this work.

When it comes to retrying an x number of times, I am not sure how this is done. Axon simply uses Spring AMQP to read messages, so most likely you need to configure Spring AMQP to do this.

The error handling in event processing is about retrying on the client side (when it doesn’t involve requeueing a message). Probably, you could leverage that to requeue messages that failed execution to AMQP with custom headers. However, I don’t have any examples of that available.