Manual ack with Spring Cloud Stream RabbitMQ

夙愿已清 提交于 2019-12-06 00:24:48

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.

@StreamListener(target = BAR)
public void handlerMethod(@Payload Foo foo,
                          @Header(AmqpHeaders.CHANNEL) Channel channel,
                          @Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) {
    ...
    channel.basickAck(deliveryTag, false);
}

The headers are added in automatic way by RabbitMQ so you can use them out of the box with your setting.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!