how to connect to Amazon MQ from masstransit

504 views
Skip to first unread message

Sini Venugopal

unread,
Nov 26, 2020, 11:15:18 AM11/26/20
to masstransit-discuss
Am migrating the masstransit- rabbitmq to Aws managed rabbitMQ for the .net application. How to connect aws managed rabbitmq from masstransit?

Thank you!

Chris Patterson

unread,
Nov 26, 2020, 2:47:41 PM11/26/20
to masstrans...@googlegroups.com
It should just work, using the network address, virtual host name, and credentials from the Amazon Management Console. You likely need to enable SSL, that would be my guess.

On Thu, Nov 26, 2020 at 10:15 AM sini <sinive...@gmail.com> wrote:
Am migrating the masstransit- rabbitmq to Aws managed rabbitMQ for the .net application. How to connect aws managed rabbitmq from masstransit?

Thank you!

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/84a9423a-68ac-4cf9-94a6-3f2792db561cn%40googlegroups.com.

Chris Patterson

unread,
Nov 26, 2020, 3:05:15 PM11/26/20
to masstrans...@googlegroups.com
Yep, works as expected. Take the URL from the console (amqps://......., including the port), and then configure it as shown:

var bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
{
    cfg.Host(new Uri("amqps://b-....mq.us-east-2.amazonaws.com:5671"), h =>
    {
        h.Username("username");
        h.Password("password");
    });

    cfg.ReceiveEndpoint("input-queue", e =>
    {
        e.Handler<PingMessage>(async context =>
        {
        });
    });
});

Sini Venugopal

unread,
Nov 27, 2020, 2:22:16 AM11/27/20
to masstrans...@googlegroups.com
Hi Chris,

Have tried the option suggested, but received an error - Start canceled: rabb...@b-xxxxxxxxxxxxxxxxxxxxxx.mq.ap-south-1.amazonaws.com:5671/
Have used amqps endpoints and configurations exactly same as you mentioned. 
Should I be using any specific version of masstransit & masstransit.RaabbitMqtransport dll?  

Thank you


Chris Patterson

unread,
Nov 27, 2020, 9:25:54 AM11/27/20
to masstrans...@googlegroups.com
I used the latest, not sure what you're using. Works fine for me, make sure you've configured the broker correctly with the right network visibility.

Good luck.


Sini Venugopal

unread,
Nov 30, 2020, 11:47:26 AM11/30/20
to masstrans...@googlegroups.com
Hi Chris,
I am also using the latest of masstransit. [7.0.7]
Below is my sample code. and the reference for the project.

using MassTransit;
using System;
namespace amqpRabbitMQ
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
                {
                    cfg.Host(new Uri("amqps://xxxxxxxxxx.mq.ap-south-1.amazonaws.com:5671"), h =>
                    {
                        h.Username("rabbitmq");
                        h.Password("password");
                    });
                });
                busControl.Start();
                Console.WriteLine("bus started");
                busControl.Publish<SampleMessage>(new
                {
                    Value = "Sample Data to queue"
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }
    }
       
    public interface SampleMessage
    {
        string Value { get; }
    }
}


image.png

Do you find anything wrong in the code/reference?

Thank you!

Reply all
Reply to author
Forward
0 new messages