RabbitMQ basic.get 和确认
我正在调用:
GetResponse response = channel.basicGet("some.queue", false); // no auto-ack
....
channel.basicAck(deliveryTag, ...);
但是,当我调用 basicGet
时,队列中的消息保持“就绪”状态,而不是“未确认”状态。我希望它们处于未确认状态,以便我可以 basic.ack
它们(从而从队列中丢弃它们),或者 basic.nack
它们
I'm invoking:
GetResponse response = channel.basicGet("some.queue", false); // no auto-ack
....
channel.basicAck(deliveryTag, ...);
However, when I invoke basicGet
, the messages in the queue stay in "Ready", rather than in "Unacknowledged". I want them to be in unacknowledged, so that I can either basic.ack
them (thus discarding them from the queue), or basic.nack
them
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在执行以下操作来模仿延迟确认:
在消费时从
123456 是消息的唯一 ID。
设置以下属性
超时)
TTL 到期时的初始队列。
在确认时
.getBody ()
).这会将其从待处理队列中删除,从而防止 TTL 将其重新排队
。备注
I'm doing the following to mimic Delaying the ack:
At consumption time
123456 is a unique id of the message.
Set the following properties
timeout)
the initial Queue upon TTL expiration.
At Acknowledge time
.getBody()
).That'll delete it from this pending queue, preventing the TTL to requeue it
Remarks
在
get
之后立即执行ack
时,效果很好。然而,就我而言,他们是因一个请求而分开的。 spring 的模板会在每次执行时关闭通道和连接。因此,存在三种选择:在前两种情况下,你不能使用 spring 的 RabbitTemplate 来做到这一点
When doing
ack
immediately after theget
it works fine. However, in my case, they were separated by a request. And spring's template closes the channel and connection on each execution. So there are three options:In the former two cases you can't do it with spring's
RabbitTemplate