rabbitmq-channel断网后没有断开情况记录
现象
队列中一直有unacked数据
复现
监听队列,使用不自动应答模式,拿到消息不应答,断开网络,关闭进程
rabbitmq中channel一直存在,state为idle状态
只能强制手动关闭连接
疑问
- rabbitmq对于tcp连接断开的心跳时间?
- 默认30分钟,根据rabbitmq.conf中
consumer_timeout
确定
- 默认30分钟,根据rabbitmq.conf中
- 如何处理网络异常断开的unacked消息?
- 等待连接超时,或强制断开channel
解答
If a consumer does not ack its delivery for more than the timeout value (30 minutes by default), its channel will be closed with a
PRECONDITION_FAILED
channel exception. The error will be logged by the node that the consumer was connected to.
The timeout value is configurable in [rabbitmq.conf] (in milliseconds):
# 30 minutes in milliseconds
consumer_timeout = 1800000