问题描述:Docker容器启动RabbitMQ以后,本地环境使用Spring Cloud连接RabbitMQ,结果报错:
o.s.b.a.amqp.RabbitHealthIndicator : Rabbit health check failed
org.springframework.amqp.AmqpAuthenticationException:
com.rabbitmq.client.AuthenticationFailureException:
ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN.
For details see the broker logfile
解决方法:连接到RabbitMQ时需要做健康检查,这个时候有两种方案来处理这个问题
第一种:配置完整的健康检查
例如项目中的yml文件中关于Spring Cloud配置的RabbitMQ如下所示:
spring:
cloud:
stream:
default-binder: rabbit
binders:
rabbit:
type: rabbit
environment:
spring:
rabbitmq:
host: 127.0.0.1
port: 5672
virtual-host: /
username: admin
password: