java - 具有 RabbitMQ 客户端身份验证异常的 QPID 代理

标签 java authentication rabbitmq amqp qpid

我正在使用 Java QPID 代理进行测试。我能够使用质子客户端发送和接收消息,但使用匿名身份验证。我有兴趣在打开身份验证的情况下进行测试,并且了解质子客户端不支持(目前)。因此,我下载了 rabbitMQ 客户端 jar。我正在使用密码文件身份验证(QPID 随附)。

我这样设置我的 RabbitMQ 客户端连接工厂:

    connectionFactory = new ConnectionFactory();
    connectionFactory.setHost("localhost");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");

代码在此行失败(特别是在 getConnection 上)。

    connection = RabbitMQConnectionFactory.getInstance().getConnection();

这是异常(exception)情况:

java.io.IOException: No compatible authentication mechanism found - server offered [CRAM-MD5] at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:309) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:590) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612) at com.vue.rabbit.core.RabbitMQConnectionFactory.getConnection(RabbitMQConnectionFactory.java:37) at com.vue.rabbit.producer.SimpleProducer.main(SimpleProducer.java:25)

如果我将 QPID 代理更改为使用匿名身份验证并将客户端更改为不设置用户/密码,我会得到类似的异常“服务器提供 [ANONYMOUS]”

我做错了什么吗?这些应该兼容?有点不同的问题是,如果 Java 和 C++ QPID 代理都支持相同的在线 AMQP 协议(protocol),为什么会有它们?在此先感谢您的帮助!

最佳答案

实际上,最新的 QPID 支持 plain SASL,但不推荐使用。查看documentation .在您的 config.json 中包含如下内容:"secureOnlyMechanisms": [] 如:

 "authenticationproviders" : [ {
    "id" : "798fc4a5-8edb-4b42-b1b2-8f7e9be8cccb",
    "name" : "passwordFile",
    "type" : "PlainPasswordFile",
    "path" : "${qpid.home_dir}${file.separator}etc${file.separator}passwd",
    "secureOnlyMechanisms": [],
    "preferencesproviders" : [ {
      "id" : "1dcee789-be1b-49cc-9032-3bc4b974d1d6",
      "name" : "fileSystemPreferences",
      "type" : "FileSystemPreferences",
      "path" : "${qpid.work_dir}${file.separator}user.preferences.json"
    } ]

关于java - 具有 RabbitMQ 客户端身份验证异常的 QPID 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26390854/

相关文章:

java - 如何隐藏 SWT 组合,使其不占用空间?

python - 是否可以在 RabbitMQ 队列之间移动/合并消息?

docker - 在docker中使用rabbitmqadmin

java - 未找到类异常,但它位于同一个包中

Java 扫描器故障 : how to skip to the next line?

mongodb - GMongo 中可以进行身份​​验证吗?

php - Symfony 2 登录后做一些额外的工作

c# - 简单登录 C# 和 MySQL Web 应用程序

logging - 如何记录所有 Rabbit MQ 消息?

java - 管理我的托管 bean 中的事务回滚