我无法使用 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
此代码段用于连接代理:
var endpoint = "amqp+ssl://*my-broker-url*.amazonaws.com:5671";
var connectionFactory = new NmsConnectionFactory(endpoint);
var connection = connectionFactory.CreateConnection("myTestUserName", "myTestPassword");
connection.Start();
当使用上面指定的代码片段和代理 URL 时,调用connection.Start()
方法时出现以下异常:Apache.NMS.NMSException: Failed to create Provider instance for amqp+ssl
经过一些研究,我意识到应该为amqp+ssl
传输连接器配置代理,我根据AMQP的ActiveMQ 文档尝试过。所以我尝试将以下 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 代理,如果我在这里缺少什么?