RabbitMQ在客户机确认消息已被处理时没有超时:请参阅this post(整个线程可能会引起兴趣)。帖子中的一些要点:The AMQP ack model for subscriptions
and "pull" are identical. In both
cases the message is kept on the
server but is unavailable to other
consumers until it either has been
ack'ed (and gets removed), nack'ed
(with basic.reject; though RabbitMQ
does not implement that) or the
channel/connection is closed (at which
point the message becomes available
to other consumers).
(我的重点)There is no timeout on waiting for
acks. Usually that is not a problem
since the common cases of a missing
ack - network or client failure -
will result in the connection getting
dropped (and thus trigger the
behaviour described above). Still,
a timeout could be useful to, say,
deal with alive but unresponsive
consumers. That has come up in
discussion before. Is there a specific
use case you have in mind that
requires such functionality?
这个问题很可能发生,因为在客户机拉取模型中,服务器很难检测到断开的连接(而不是活动但无响应的消费者),特别是服务器似乎乐于永远等待ack。
更新:在Linux上,您可以附加SIGTERM和/或SIGKILL和/或SIGINT的信号处理程序,并希望以有序的方式从客户端关闭连接。在Windows上,我相信从任务管理器关闭会调用Win32TerminateProcessAPI,MSDN对此说:If a process is terminated by
TerminateProcess, all threads of the
process are terminated immediately
with no chance to run additional code.
This means that the thread does not
execute code in termination handler
blocks. In addition, no attached DLLs
are notified that the process is
detaching.
这意味着可能很难有秩序地终止和关闭。
可能值得在RabbitMQ列表中使用您自己的ack超时用例。