Announcement Announcement Module
No announcement yet.
Sending requeue=false on failure Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending requeue=false on failure

    Currently, when there is an exception in a listener, the container's BlockingQueueConsumer does this:
    channel.basicReject(deliveryTag, true);

    However, we want to send requeue=false in these cases. An additional requirement is to send failed messages to a separate queue ("failed.messages").
    Currently I implemented that by copy-pasting a couple of spring-rabbit/amqp classes and changed the desired pieces of code, but that's ugly. Any better approach?

  • #2
    basicReject() is only called if you use acknowledgeMode=AUTO, so maybe you just need to use acknowledgeMode=NONE? What would be the benefit of AUTO if you didn't ask the broker to redeliver - maybe if it is a common use case we can expose a flag or something?

    For the failed message queue, you could put the logic in your listener - catch exceptions and decide for each one whether to send the message to the failed queue - or you could do that declaratively with a retry interceptor in the advice chain of the listener container. There should be some samples of that in the integration tests. This is something we have considered making a first class feature of the framework, so if you like the idea a lot raise a JIRA and/or contribute some code.


    • #3
      Where do I catch the exception? The listener's onMessage won't see the queue-related exceptions.


      • #4
        What is "queue-related"? Can you describe an example failure scenario in a bit more detail?