Temporary queues in RabbitMQ

MailerQ dynamically creates temporary queues in RabbitMQ when specific situations arise during email delivery. These queues help optimize the delivery process by allowing MailerQ to manage different traffic patterns without interrupting the flow of regular email deliveries.

Purpose of temporary queues

Temporary queues are created by MailerQ when a part of the email delivery process is paused or throttled. This could happen under conditions like:

In such cases, a temporary queue is created, and all similar messages are routed to this queue. These queues are read at a slower rate compared to the main outbox queue, allowing MailerQ to pause a part of the delivery while continuing to send emails at the normal rate for other destinations.

MailerQ automatically creates these temporary queues on the fly at runtime, and the configuration file allows you to control the creation and removal of these queues with several settings.

Naming conventions

Temporary queues follow a predictable naming convention. For example:

Where the "from" and "to" indicate the sender IP addresses and target domain name. The "id" is a random string to avoid naming clashes.

Configuration options

There are a couple of config file variables that can be used to control temporary queue creation:

temporary-type:         classic
temporary-exchange:     my-exchange
temporary-declare:      true
temporary-durable:      true

The temporary queues are declared on the fly by MailerQ. By default, MailerQ created classic RabbitMQ queues. The setting temporary-type can be used to override this, and instruct MailerQ to create quorum queues instead.

All temporary queues are bound to an exchange, to which the messages are published. The temporary-exchange setting allows you to specify this exchange. When not set, it uses the same value as the rabbitmq-exchange setting, which in turn defaults to "mailerq". If you leave this option empty, MailerQ will not bind the temporary queues to an exchange, and will publish messages using the default exchange. This can be more efficient as it saves declare-queue instructions.

On application startup, the configured exchange is automatically declared, unless the option temporary-declare is set to false. If you set it to false, please make sure that you set up the exchange yourself. The temporary-durable setting is only relevant when temporary-declare is set to true, and controls whether the exchange is created with the durable flag.