Vinayak Dinesh
Vinayak Dinesh

Reputation: 13

Unable to set connector as AMQP when connecting to ActiveMQ using MassTransit

Using MassTransit I'm trying to connect to ActiveMQ using AMQP connector. MassTransit is configured to connect using OpenWire connector to port 61616.

Created a local container for ActiveMq using the following command

docker run --rm -d -p 5672:5672 -p 8161:8161 rmohr/activemq:5.15.6-alpine

Now when trying to connect to MassTransit I am passing the Port 5672

var uriBuilder = new UriBuilder("amqp://localhost")
                {
                    Port = 5672
                };

                var serviceBusHost = cfg.Host(
                    uriBuilder.Uri, settings =>
                    {
                        settings.Password(credentials[0]);
                        settings.Username(credentials[1]);
                    });

On using the above piece of code in activeMqBusFactory I run into the following exception: MassTransit.ActiveMqTransport.ActiveMqTransportConfigurationException: 'The address scheme was invalid: amqp'

On changing the above code to

var uriBuilder = new UriBuilder("activemq://localhost")
                {
                    Port = 5672
                };

                var serviceBusHost = cfg.Host(
                    uriBuilder.Uri, settings =>
                    {
                        settings.Password(credentials[0]);
                        settings.Username(credentials[1]);
                    });

I get no exception but the webApp gets stuck with message Starting bus hosts... Connecting: admin@localhost:5672

Just to clarify if I expose the port 61616 when running the docker container and use the following code

var uriBuilder = new UriBuilder("activemq://localhost")
                {
                    Port = 61616
                };

                var serviceBusHost = cfg.Host(
                    uriBuilder.Uri, settings =>
                    {
                        settings.Password(credentials[0]);
                        settings.Username(credentials[1]);
                    });

I am able to connect to activeMQ using OpenWire Connector. I am looking for a way to connect using AMQP connector.

Thanks

Upvotes: 1

Views: 1273

Answers (1)

Tim Bish
Tim Bish

Reputation: 18356

Looking at the source for MassTransit it would appear that you can't use an AMQP connection to an ActiveMQ broker right now. The code uses the NMS.ActiveMQ library which is openwire only so you need to stick with that. The authors would need to support AMQP as a protocol connector using something like the AmqpNetLite client as a general purpose AMQP connector for any message platform that supports it.

Upvotes: 1

Related Questions