SpringBoot应用启动后连接RabbitMQ失败

580 阅读1分钟

问题描述:

Restarting Consumer: tags=[[]], channel=null, acknowledgeMode=MANUAL local queue size=0

SpringBoot启动后,在RabbitMQ管理界面中无队列创建,查看日志提示信息:

[org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-303] ERROR o.s.a.r.listener.SimpleMessageListenerContainer - Failed to check/redeclare auto-delete queue(s).
[AMQP Connection MQ实例主机ip+端口] WARN  com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred (Exception message: Socket closed)
[org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#1-303] INFO  o.s.a.rabbit.connection.CachingConnectionFactory - Attempting to connect to: [MQ实例主机ip+端口]
[org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-302] INFO  o.s.a.r.listener.SimpleMessageListenerContainer - Restarting Consumer: tags=[[]], channel=null, acknowledgeMode=MANUAL local queue size=0
[AMQP Connection MQ实例主机ip+端口] WARN  com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred (Exception message: Socket closed)
[org.springframework.amqp.rabbit.RabbitListenerEndpointContainer#0-304] INFO  o.s.a.rabbit.connection.CachingConnectionFactory - Attempting to connect to: [MQ实例主机ip+端口]

解决方案:

  1. 检查配置文件中配置的RabbitMQ的host、port、账号密码、virtual-host 填写的是否正确
  2. 在部署应用的服务器上 telnet 一下RabbitMQ的实例,检查网络是否连通
  3. 检查使用的账号的权限是否正常,是否可以自动创建队列
  4. 如果是因为账户权限不够,需要协调提供方实现创建好队列