Connecting to AmazonMQ (ActiveMQ) broker from .NET using Apache.NMS.AMQP

2.7k Views Asked by At

I am having trouble connecting to my AmazonMQ broker using Apache.NMS.AMQP client (GitHub repo).

I have AmazonMQ broker up and running and I can connect to broker console. In my .NET project I have installed Apache.NMQ.AMQP NuGet (v1.8.0) which should be used to connect to ActiveMQ brokers over AMQP.

According to AWS console for Amazon MQ this is the brokers AMQP endpoint, notice amqp+ssl schema:

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

This code snippet is used to connect to broker:

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

connection.Start();

When using above specified code snippet and broker URL I get following exception when calling connection.Start() method: Apache.NMS.NMSException: Failed to create Provider instance for amqp+ssl

After some research I've realised that broker should be configured for amqp+ssl transport connector which I've tried according to ActiveMQ documentation for AMQP. So I have tried adding following XML to broker configuration:

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

When trying to save edited configuration AWS presents me the following message:

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.

Which, I suppose, means that only 'openwire' transport connector is allowed to be specified in configiration.

The next solution that I've tried is changing broker URL to use amqp schema so I got following:

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

instead of

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

which also threw me an exception when calling connection.Start() with following message:

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.

Is there any way to connect to Amazon managed ActiveMQ broker using AMQP protocol and .NET and if there is what am I missing here?

1

There are 1 best solutions below

1
On BEST ANSWER

I faced the same scenario in java, mine got resolved by replacing "amqp+ssl" with "amqps":

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