我无法使用Apache. NMS.AMQP客户端(GitHub repo)连接到我的Amazon MQ代理。
我有Amazon MQ代理启动并运行,我可以连接到代理控制台。在我的.NET项目中,我安装了Apache. NMQ.AMQP NuGet(v1.8.0),它应该用于通过AMQP连接到ActiveMQ代理。
根据亚马逊AWS控制台MQ这是经纪人的AMQPendpoint,请注意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我得到以下异常时调用连接. Start()
方法:Apache.NMS.NMSException:无法创建提供程序实例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";
当使用以下消息调用connect. 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.
有没有办法连接到亚马逊管理的ActiveMQ代理使用AMQP协议和.NET,如果有什么我错过了这里?
我在java遇到了同样的情况,我的问题通过用“amqps”替换“amqp ssl”得到了解决:
var endpoint = "amqps://*my-broker-url*.amazonaws.com:5671";