Search code examples
javaspringspring-bootrabbitmqamqp

spring boot cannot connect to rabbitmq


I have a RabbitMQ server like this
enter image description here

When I try to connect to this server via Spring Boot amqp, I see com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

My configs are this one

# Message
spring.activemq.broker-url=tcp://127.0.0.1:5672
spring.activemq.user=test
spring.activemq.password=test

Yes, the user test can access Virtual Hosts on / and yes, I can login with test/test on RabbitMQ GUI

EDIT

Looking at the rabbitmq logs, I saw this

{handshake_error,starting,0,
             {amqp_error,access_refused,
                         "PLAIN login refused: user 'guest' - invalid credentials",
                         'connection.start_ok'}}

seems like Spring is ignoring my configs and trying to connect with guest


Solution

  • Spring Properties includes specific settings for RabbitMQ. Try replacing your ActiveMQ config with below.

    Example:

    spring.rabbitmq.host = 127.0.0.1
    spring.rabbitmq.port = 5672
    spring.rabbitmq.username = guest
    spring.rabbitmq.password = guest