In rabbitmq, the client has not acked for 30 minutes and reported an error

Error reproduction:

Unhandled exception. RabbitMQ.Client.Exceptions.AlreadyClosedException: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text='PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more', classId=0, methodId=0

This error occurs on the RabbitMQ client, indicating that the connection has been closed and giving the reason for the closure:

  • close-reason, initiated by the peer (Peer);
  • code=406, display PRECONDITION_FAILED;
  • text='PRECONDITION_FAILED - delivery acknowledgment on channel 1 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn more', indicating that it is because of a channel named "channel 1" The message acknowledgment timed out and was not acknowledged within the allotted time. Here, the timeout value is 1800000 milliseconds (30 minutes).

So how to solve it, just configure the timeout time of ack, the official description:
https://www.rabbitmq.com/consumers.html#acknowledgment-timeout

If you are in a docker environment, there is a pitfall, that is, the configuration through environment variables consumer_timeout does not take effect, as follows:

version: "3"
services:
  rabbitmq:
    image: rabbitmq:3.8-management-alpine
    environment:
      - RABBITMQ_CONSUMER_TIMEOUT=600000 # 设置consumer_timeout参数为600000毫秒

The parameters need to be set dynamically in the configuration file:

version: "3"
services:
  rabbitmq:
    image: rabbitmq:3.8-management-alpine
    volumes:
      - ./rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
    environment:
      - RABBITMQ_CONFIG_FILE=/etc/rabbitmq/rabbitmq.conf

In the rabbitmq.conf file, set the consumer_timeout parameter. as follows:

default_pass = guest
default_user = guest
default_vhost = /
consumer_timeout = 600000

Guess you like

Origin blog.csdn.net/weixin_43702146/article/details/129580443