使用 pecl-amqp 防止在 get() 上确认消息
我正在尝试将 pecl-amqp 用于我的项目。但我在 ACK 过程中遇到了困难。我需要手动确认从队列中收到的每条消息,但在检索消息时,这些消息似乎会自动确认。
我已将队列设置为 AMQP_NOACK 并使用 AMQPQueue->get(AMQP_NOACK) 但似乎没有任何影响,消息仍然从队列中删除,而无需我发送 AMQPQueue->ack()。
如果有人对 pecl-amqp 有任何经验,我将不胜感激。
I'm attempting to use pecl-amqp for a project of mine. I'm having difficulties though with the ACK process. I need to manually ACK each message I receive off a queue, but the messages appear to be auto-ACKing when the message is retrieved.
I've set my queue to AMQP_NOACK and am using AMQPQueue->get(AMQP_NOACK) but none of it seems to have any affect, the messages are still removed from the queue without me sending AMQPQueue->ack().
If anyone has any experience with the pecl-amqp I would appreciate the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了同样的问题,但已经设法使用 Consumer 方法让确认机制正常工作。使用rabbitmqctl列出队列中的条目似乎工作正常,尽管我似乎以与发送消息的顺序不同的顺序将消息从队列中取出——这会破坏队列的对象。我的代码如下:
I have been having the same problem but have managed to get the acknowledge mechanism to work using the consume method. Using rabbitmqctl to list the entries in the queue it appears to work OK, though I seems to be getting the messages off the queue in a different order to that in which they were sent - which kind of defeats the object of a queue. My code is as follows:
作为参考,AMQP 扩展未正确支持 AMQP_NOACK。你可以让它做你想做的事,但它并不漂亮。我现在正在努力解决这个问题。仅供参考,AMQP_NOACK 意味着您稍后不必返回确认消息,即服务器将消息发送到客户端后,服务器会将消息标记为已确认。围绕这个问题有些困惑,所以我想澄清一下。
For reference, the AMQP extension did not support the AMQP_NOACK correctly. You can get it to do what you want, but it isnt pretty. I am working on fixing that now. FYI, AMQP_NOACK means that you will not have to come back to acknowledge the message later, i.e. as soon as the server sends the message to the client, the server marks the message as ack'ed. There has been some confusion around this, so I wanted to clarify.