【问题标题】:Connecting to AmazonMQ (ActiveMQ) broker from .NET using Apache.NMS.AMQP使用 Apache.NMS.AMQP 从 .NET 连接到 AmazonMQ (ActiveMQ) 代理
【发布时间】:2020-04-12 07:14:10
【问题描述】:

我在使用 Apache.NMS.AMQP 客户端 (GitHub repo) 连接到我的 AmazonMQ 代理时遇到问题。

我已经启动并运行了 AmazonMQ 代理,我可以连接到代理控制台。 在我的 .NET 项目中,我安装了 Apache.NMQ.AMQP NuGet (v1.8.0),它应该用于通过 AMQP 连接到 ActiveMQ 代理。

根据 Amazon MQ 的 AWS 控制台,这是代理 AMQP 端点,请注意 amqp+ssl 架构:

amqp+ssl://*my-broker-url*.amazonaws.com:5671

这段代码sn-p用来连接broker:

var endpoint = "amqp+ssl://*my-broker-url*.amazonaws.com:5671";
var connectionFactory = new NmsConnectionFactory(endpoint);
var connection = connectionFactory.CreateConnection("myTestUserName", "myTestPassword");

connection.Start();

当使用上面指定的代码 sn-p 和代理 URL 时,调用 connection.Start() 方法时出现以下异常:Apache.NMS.NMSException: Failed to create Provider instance for amqp+ssl

经过一些研究,我意识到应该为 amqp+ssl 传输连接器配置代理,我根据 ActiveMQ documentation 为 AMQP 尝试过。所以我尝试将以下 XML 添加到代理配置:

<broker>
    <!-- some other configuration entries -->
    <transportConnectors>
        <transportConnector name="amqp+ssl" uri="amqp+ssl://localhost:5671"/>
    </transportConnectors>
    <!-- some other configuration entries -->
</broker>

当尝试保存已编辑的配置时,AWS 向我显示以下消息:

The specified XML configuration data is invalid: cvc-attribute.3: 
The value 'amqp+ssl' of attribute 'name' on element 'transportConnector' is not valid with respect to its type,
'protocol'. and cvc-enumeration-valid: 
Value 'amqp+ssl' is not facet-valid with respect to enumeration '[openwire]'. 
It must be a value from the enumeration.

我想这意味着只允许在配置中指定“openwire”传输连接器。

我尝试的下一个解决方案是将代理 URL 更改为使用 amqp 架构,因此我得到了以下结果:

var endpoint = "amqp://*my-broker-url*.amazonaws.com:5672";

而不是

var endpoint = "amqp+ssl://*my-broker-url*.amazonaws.com:5671";

在使用以下消息调用 connection.Start() 时也引发了异常:

Apache.NMS.NMSException: 
A connection attempt failed because the connected party did not properly respond after a period of time, 
or established connection failed because connected host has failed to respond.

有什么方法可以使用 AMQP 协议和 .NET 连接到 Amazon 托管的 ActiveMQ 代理,如果我在这里遗漏了什么?

【问题讨论】:

    标签: .net activemq amqp amazon-mq apache-nms


    【解决方案1】:

    我在java中遇到了同样的情况,我的解决方法是用“amqp+ssl”替换 “amqps”:

    var endpoint = "amqps://*my-broker-url*.amazonaws.com:5671";
    

    【讨论】:

    猜你喜欢
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    • 2017-01-05
    • 2022-12-17
    • 2019-07-15
    • 2019-08-08
    相关资源
    最近更新 更多