gpt4 book ai didi

rabbitmq - Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录

转载 作者:行者123 更新时间:2023-12-03 05:13:02 35 4
gpt4 key购买 nike

我遇到了异常

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

配置:Windows 上的 RabbitMQ 3.3.5

%APPDATA%\RabbitMQ\rabbit.config 中的配置文件我已按照 https://www.rabbitmq.com/access-control.html 进行了以下更改

[{rabbit, [{loopback_users, []}]}].

我还尝试创建用户/密码 - test/test 似乎无法使其工作。

尝试了 this 中的步骤发布。

其他配置详情如下:

Tomcat 托管 Spring 应用程序上下文:

<!-- Rabbit MQ configuration Start -->
<!-- Connection Factory -->
<rabbit:connection-factory id="rabbitConnFactory" virtual-host="/" username="guest" password="guest" port="5672"/>

<!-- Spring AMQP Template -->
<rabbit:template id="rabbitTemplate" connection-factory="rabbitConnFactory" routing-key="ecl.down.queue" queue="ecl.down.queue" />

<!-- Spring AMQP Admin -->
<rabbit:admin id="admin" connection-factory="rabbitConnFactory"/>

<rabbit:queue id="ecl.down.queue" name="ecl.down.queue" />

<rabbit:direct-exchange name="ecl.down.exchange">
<rabbit:bindings>
<rabbit:binding key="ecl.down.key" queue="ecl.down.queue"/>
</rabbit:bindings>
</rabbit:direct-exchange>

在我的 Controller 类中

@Autowired
RmqMessageSender rmqMessageSender;

//Inside a method
rmqMessageSender.submitToECLDown(orderInSession.getOrderNo());

在我的消息发件人中:

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("messageSender")
public class RmqMessageSender {

@Autowired
AmqpTemplate rabbitTemplate;

public void submitToRMQ(String orderId){
try{
rabbitTemplate.convertAndSend("Hello World");
} catch (Exception e){
LOGGER.error(e.getMessage());
}
}
}

上面的异常 block 给出了下面的异常

<小时/>

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

<小时/>

错误日志

  =ERROR REPORT==== 7-Nov-2014::18:04:37 ===
closing AMQP connection <0.489.0> (10.1.XX.2XX:52298 -> 10.1.XX.2XX:5672):
{handshake_error,starting,0,
{amqp_error,access_refused,
"PLAIN login refused: user 'guest' can only connect via localhost",
'connection.start_ok'}}

请在 pom.xml 条目下面找到

        <dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>

如果您有任何想法/建议,请告诉我

最佳答案

我确信 Artem Bilan 已经解释过了 here可能是此错误的原因之一:

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

但对我来说,解决方案是我使用默认用户名和密码(guest/guest)登录到rabbitMQ管理页面( http://localhost:15672/#/users ),然后添加一个新用户,并为该新用户启用了访问权限它来自虚拟主机,然后使用新的用户名和密码而不是默认的 guest ,从而清除了错误。

enter image description here

关于rabbitmq - Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26811924/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com