rabbitmq Broker not available; cannot force queue declarations during start: java.util.concurrent.TimeoutException

发布时间 2023-09-20 14:35:43作者: 飘杨......

一、概述

  使用SpringBoot集成RabbitMQ遇到的问题。

2023-09-20 14:19:39.655  INFO 10256 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2023-09-20 14:19:39.656  INFO 10256 --- [  restartedMain] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to:主机ip:15672
2023-09-20 14:19:44.687  INFO 10256 --- [  restartedMain] o.s.a.r.l.SimpleMessageListenerContainer : Broker not available; cannot force queue declarations during start: java.util.concurrent.TimeoutException
2023-09-20 14:19:44.692  INFO 10256 --- [sageContainer-1] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: 主机ip:15672
2023-09-20 14:19:49.704 ERROR 10256 --- [.68.165.5:15672] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occurred

 

二、解决办法

  我这里是因为RabbitMQ的web访问端口是15672,而RabbitMQ-Server的访问端口是5672.而我在配置application.yml的时候配置的端口是5672,端口对照不上所以出现了连接超时的问题。

  解决办法就是把application.yml中的rabbitmq的端口号改为6572就行了。ps:如果这里你自定义了端口,就要按照自定义端口来。

  rabbitmq:
    host: 远程主机ip/域名
    port: 5672
    username: rabbitmq账号
    password: rabbitmq密码