3
@Configuration
@EnableRabbit
public class RabbitConfiguration {

    private static final String queueName = "3055";

    private static final String topicExchangeName = queueName + "-exchange";

    @Bean
    Queue queue() {
        return new Queue(queueName, false);
    }

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(topicExchangeName);
    }

    @Bean
    Binding binding(Queue queue, TopicExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("foo.bar.#");
    }

    @Bean
    RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory,
                                  MessageConverter messageConverter) {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
        rabbitTemplate.setMessageConverter(messageConverter);
        return rabbitTemplate;
    }

    @Bean
    MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

}

Code above is my Spring Boot Project's RabbitMQ configuration class.

However, I cannot connect the RMQ server since below error pops up every time I try to connect.

Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

The Server provider told me that I need to set the authentication mechanism to AMQPLAIN.

My question is that How can I set authentication mechanism to AMQPLAIN?

No matter how much I google, I couldn't figure out how.

Kigael Lee
  • 119
  • 1
  • 8
  • This is usually invalid credentials or access permissions. Also the username is case sensitive. There may also be cases that your username may contain extra space at the end... – Raja Anbazhagan Sep 02 '20 at 03:16
  • Does this answer your question? [Spring AMQP + RabbitMQ 3.3.5 ACCESS\_REFUSED - Login was refused using authentication mechanism PLAIN](https://stackoverflow.com/questions/26811924/spring-amqp-rabbitmq-3-3-5-access-refused-login-was-refused-using-authentica) – Player One Sep 02 '20 at 03:18

1 Answers1

1

I confirm to @Raja Anbazhagan. Check the RabbitMQ logs first. Supposedly your user credentials were guest/guest.

The easiest way to solve your problem could be to add those lines in your application.yml:

spring:
  rabbitmq:
    username: <user-name>
    password: <user-password>
Josef
  • 2,869
  • 2
  • 22
  • 23
74smoky
  • 43
  • 1
  • 7