我无法使用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
传输连接器配置代理,而我已经根据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代理,如果我在这里缺少什么?
我在Java中遇到了相同的情况,我的解决方法是将“ amqp + ssl”替换为“ amqps”:
var endpoint = "amqps://*my-broker-url*.amazonaws.com:5671";