spring boot - Retry Configuration for @RabbitListener programatically specify dead-letter queue -


i've been trying find way set retry mechanism @rabbitlistener's. i've tried properties:

listener:   auto-startup: true   concurrency: 1   max-concurrency: 1   retry:     enabled: true     initial-interval: 1000     max-attempts: 3     max-interval: 10000     multiplier: 2     stateless: true 

and works fine with problem no error sent message. problem have in order send messages specific dlq have change queues add arguments x-dead-letter-exchange , x-dead-letter-routing-key , that's avoid.

so questions is:

  1. is there way programmatically specify dlq messages should go after exhausting attempts without re-creating queues? not using arguments x-dead-...

i'm using spring boot 1.4.0.release.

not via properties.

you have override listener container factory's advice chain own retry interceptor - built retryinterceptorbuilder - instead of injecting

builder.recoverer(new rejectanddontrequeuerecoverer()); 

you need inject appropriately configured republishmessagerecoverer - publishing exchange of choice, adds additional information (stack trace etc) message headers.

see simplerabbitlistenercontainerfactoryconfigurer see how default interceptor built properties.

the republishing recoverer discussed in this section of spring amqp docs.


Comments