2

I have dead lettering set up for a few queues that I am using. In the configuration I use:

<bean id="retryAdvice"
    class="org.springframework.amqp.rabbit.config.StatefulRetryOperationsInterceptorFactoryBean">
    <property name="messageRecoverer" ref="rejectAndDontRequeueRecoverer"/>
    <property name="retryOperations" ref="retryTemplate" />
</bean>

<bean id="rejectAndDontRequeueRecoverer" class="org.springframework.amqp.rabbit.retry.RejectAndDontRequeueRecoverer"/>

If i want the message on the dead letter queue to have the x-exception-stacktrace , I read that I need to use RepublishMessageRecoverer. Is using that in dead lettering as simple as replacing RejectAndDontRequeueRecoverer with RepublishMessageRecoverer in the above setting or do I need to write a custom messageRecoverer?

Nandita Rao
  • 277
  • 1
  • 4
  • 17

1 Answers1

3

Yes, just replace the recoverer. Normal RabbitMQ dead lettering is not used at all (the message will be ack'd) and you don't need to configure the DLE/DLQ; you have complete control in the recoverer over where the message goes.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • 1
    Is there anyway I can change my dead letter set up such that the message that gets published to the dead letter queue has the header x-exception-stacktrace? Or is it only available through republishMessageRecoverer? – Nandita Rao Oct 21 '14 at 16:12
  • No; Rabbit's DLE/DLQ handling knows nothing about the consumer, just that the message was rejected, so there's no way to convey any information that way. – Gary Russell Oct 21 '14 at 16:25