【发布时间】:2020-09-02 03:07:54
【问题描述】:
@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();
}
}
上面的代码是我的 Spring Boot Project 的 RabbitMQ 配置类。
但是,我无法连接 RMQ 服务器,因为每次尝试连接时都会弹出以下错误。
Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
服务器提供商告诉我需要将身份验证机制设置为 AMQPLAIN。
我的问题是如何将身份验证机制设置为 AMQPLAIN?
无论我用多少谷歌搜索,我都无法弄清楚。
【问题讨论】:
-
这通常是无效的凭据或访问权限。用户名也区分大小写。在某些情况下,您的用户名末尾可能包含额外的空格...
标签: spring-boot rabbitmq