# ActiveMQ

MassTransit.ActiveMQ (opens new window)

In the example below, the ActiveMQ settings are configured.

namespace ActiveMqConsoleListener
{
    using System;
    using System.Threading.Tasks;
    using MassTransit;
    using MassTransit.ActiveMqTransport;
    using Microsoft.Extensions.DependencyInjection;

    public class Program
    {
        public static async Task Main()
        {
            var services = new ServiceCollection();
            services.AddMassTransit(x =>
            {
                x.UsingActiveMq((context, cfg) =>
                {
                    cfg.Host("localhost", h =>
                    {
                        h.UseSsl();

                        h.Username("admin");
                        h.Password("admin");
                    });
                });
            });
        }
    }
}

The configuration includes:

  • The ActiveMQ host
    • Host name: localhost
    • User name and password used to connect to the host

The port can also be specified as an additional parameter on the Host method. If port 61617 is specified, SSL is automatically enabled.

MassTransit includes several receive endpoint level configuration options that control receive endpoint behavior.

Property Type Description
PrefetchCount ushort The number of unacknowledged messages that can be processed concurrently (default based on CPU count)
AutoDelete bool If true, the queue will be automatically deleted when the bus is stopped (default: false)
Durable bool If true, messages are persisted to disk before being acknowledged (default: true)

WARNING

When using ActiveMQ, receive endpoint queue names must not include any . characters. Using a dotted queue name will break pub/sub message routing. If using a dotted queue name is required, such as when interacting with an existing queue, disable topic binding.

endpoint.ConfigureConsumeTopology = false;

When the consume topology is not configured, the virtual consumer queues are not created.

# Amazon MQ

Amazon MQ uses ActiveMQ, so the same transport is used. Amazon MQ requires SSL, so if MassTransit detects the host name ends with amazonaws.com, SSL is automatically configured.