Skip to content

Connect MassTransit

Run .NET apps that use MassTransit on a RabbitMQ cluster over AMQPS.

Updated View as Markdown

MassTransit connects to a RabbitMQ cluster with the cluster’s name, a user and TLS. New queues are quorum queues unless the app declares another type (see Vhosts and queues).

services.AddMassTransit(x =>
{
    x.AddConsumers(typeof(Program).Assembly);
    x.UsingRabbitMq((context, cfg) =>
    {
        cfg.Host("mq-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com", 5671, "/", h =>
        {
            h.Username(username);
            h.Password(password);
            h.UseSsl(s =>
            {
                s.ServerName = "mq-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com";
                s.Protocol = SslProtocols.Tls12 | SslProtocols.Tls13;
            });
        });
        cfg.ConfigureEndpoints(context);
    });
});

Read username and password from the user’s Secret. The cluster’s certificate chains to the EZGH CA bundle: add the bundle to the trusted roots of the image or host the app runs on.

MassTransit needs no setting for quorum queues: its endpoint queues become quorum queues on a vhost whose default is quorum. This is tested with MassTransit.RabbitMQ 8.5 on .NET 10, over AMQPS and over the plaintext port.

MassTransit reconnects by itself when a connection closes. See Timeouts and reconnects.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close