Regardless the mechanism used to apply retrials on Rabbit listener, how could I know in the implementation that the current execution is the original one or a retrial after an exception.
I want to log this and also I will take action depending on it.
It depends on the type of your listener; if it's a MessageListener
you can use message.getMessageProperties().isRedelivered()
. If you are using a @RabbitListener
, add @Header(AmqpHeaders.REDELIVERED) boolean redelivered
to the method parameters.
The redelivery count is not available, just that this is a redelivery.