Announcement Announcement Module
Collapse
No announcement yet.
Namespace support for defaultRequeueRejected on amqp:channel Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Namespace support for defaultRequeueRejected on amqp:channel

    I am using an amqp-backed channel (amqp:channel). Is there a work-around to being able to stop rejected messages from being sent back to queue ? Acknowledge-mode is AUTO and channel-transacted is TRUE. I have an error-handler defined (MessagePublishingErrorHandler) that sends the error message to the errorChannel. But I don't want the original message sent back to the queue.

    Thanks.

  • #2
    I realize this is an old post, but I figured I'd post a solution for future fellow googlers. The easiest way to deal with this right now is to implement your own org.springframework.util.ErrorHandler and rethrow any exception as org.springframework.amqp.AmqpRejectAndDontRequeueE xception, say something like this:

    Code:
    @Component
    public class AmqpExceptionChannelErrorHandler implements ErrorHandler {
    
        @Override
        public void handleError(Throwable t) {
            throw new AmqpRejectAndDontRequeueException(t);
        }
    
    }
    Then set your error-handler for your amqp pubsub channel:

    Code:
    <int-amqp:publish-subscribe-channel error-handler="amqpExceptionChannelErrorHandler" id="some-channel-id"
            connection-factory="rabbitConnectionFactory" />
    Of course you'll want to DO something after this exception is thrown once and only once, but that's entirely up to your needs.

    Comment


    • #3
      Thanks for posting your solution - it looks like this question fell through the cracks, for which we apologize.

      Comment

      Working...
      X