Hi,
I'm using spring amqp with rabbitmq as my message broker.How can u acknowledge the message from the queue manually after processing it (using simplemessagelistneradapter)?
Hi,
I'm using spring amqp with rabbitmq as my message broker.How can u acknowledge the message from the queue manually after processing it (using simplemessagelistneradapter)?
Last edited by tec; Aug 11th, 2012 at 06:04 AM.
If you are using a spring-amqp listener container, you typically don't need to use manual acknowledgment - 'auto' acknowledgement in spring-amqp means the container will ack the message when the thread returns normally or reject (nack) it if an exception is thrown. This should not be confused with what rabbit calls auto-ack; that is called NONE in spring-amqp.
If, however, you do want to use manual acknowledgment, you can do so, but you have to use a ChannelAwareListener so you can invoke basicAck or basicReject.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
Hi,
for example if your consumer implements ChannelAwareMessageListener :
yannick.Code://ack messages channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
You can have your service activator on the error-channel throw an exception but, as you point out, it will loop indefinitely if the message fails every time (sometimes called a poison message). Unless you can detect/track the number of attempts and consume the message after a certain number of tries.
Yes, a retry interceptor with appropriate policies for retry and recovery can do all this for you. If you configure a RejectAndDontRequeueRecover, the poison message can be sent to the DLE.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware