Search code examples
spring-bootrabbitmqspring-amqpspring-rabbit

Custom header when requeing


I'm using SimpleMessageListenerContainer to receive messages from RabbitMq. Is there a way to add custom metadata to a message when it is nack'ed? I would like to continue processing the message from the point it failed.

I'm assuming any exception that gets thrown from a listener will cause the message to be requeued ( provided the exception is setup for that).

Thanks, Sudha


Solution

  • No. The amqp protocol only has a simple flag to requeue or not. You can use retry with a subclass of the RepublishMessageRecoverer to add headers, but it will requeue at the tail not the head. See the reference manual.