user3527917
user3527917

Reputation: 337

ActiveMQ Amqp C# ConnectionFactory and IConnectionFactory

I am using Amqp with ActiveMQ, which requires version 1-0-, not the old version 0-9-

In the version 0-9-* with "RabbitMQ.Client" (I was using RabbitMQ and switching to ActiveMQ), the following C# code works to connect to one broker.

factory = new ConnectionFactory()
                    {
                        Protocol = Protocols.FromEnvironment(),
                        HostName = IpAddress,
                        Port = Port,
                        VirtualHost = VirtualHost,
                        UserName = User,
                        Password = Password
                    };

but with version 1-0-* in "Apache.NMS.ActiveMQ", this does not work, (the example here use IConnectionFactory instead: http://activemq.apache.org/nms/examples.html but could not input HostName, Port, VirtualHost, UserName, Password there. )

How can I use "Apache.NMS.ActiveMQ", and do the connection with username, password in the code.

Thanks :)

Upvotes: 0

Views: 5089

Answers (2)

user13766217
user13766217

Reputation: 1

There is now an Apache ActiveMQ released version of Apache.NMS.AMQP its available it Nuget.

https://www.nuget.org/packages/Apache.NMS.AMQP

You can contribute

https://github.com/apache/activemq-nms-amqp

Upvotes: 0

Petter Nordlander
Petter Nordlander

Reputation: 22279

ActiveMQ is a multi protocol broker. AMQP 1.0 is one of the wire protocols it supports.

However, the Apache.NMS.ActiveMQ lib is using the OpenWire protocol (default port 61616 on AMQ). It's straight forward to connect using NMS to OpenWire, even with username and password.

IConnectionFactory factory = new ConnectionFactory("tcp://localhost:61616);
using (IConnection connection = factory.CreateConnection("user1234","s3cr3tp4ssw0rd")
{
     using (ISession session = connection.CreateSession ()) 
     {
       // send a message or whatever

If you really want to connect using AMQP, I suggest the QPid proton lib instead of NMS. NMS has something going on as well, but it's not there yet.

Upvotes: 4

Related Questions