Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manual ack with Spring Cloud Stream RabbitMQ

I'm trying to setup a scenario where the listeners will manually send ACK to RabbitMQ. I have this in my application.properties

spring.cloud.stream.rabbit.bindings.input.consumer.acknowledge-mode=MANUAL

How do I send an ack from the listener? I see from Manual Acknowledgement of Messages : Spring Cloud Stream Kafka that for Kafka, we create an Acknowledgement object and call acknowledge() in it. Is there an example for RabbitMQ to do the same?

like image 210
user3344591 Avatar asked Feb 07 '23 08:02

user3344591


1 Answers

See the Spring Integration Reference Manual. The message has two headers, AmqpHeaders.CHANNEL and AmqpHeaders.DELIVERY_TAG.

You need to call basicAck on the channel, passing in the delivery tag.

like image 117
Gary Russell Avatar answered Mar 15 '23 21:03

Gary Russell