HareMq.Queue (hare_mq v1.4.0)

Copy Markdown

Functions for declaring and binding RabbitMQ queues.

Supports three queue families:

Summary

Functions

Binds a queue to an exchange using the routing key in config.

Declares the dead-letter queue (queue_name.dead) with x-message-ttl.

Declares the delay queue(s) used by the retry pipeline.

Declares a durable RabbitMQ queue (classic or quorum).

Declares a durable RabbitMQ stream queue.

Functions

bind(config)

Binds a queue to an exchange using the routing key in config.

For stream queues the user-supplied config.exchange is used as the source exchange. For classic queues the exchange is named after the queue itself (config.queue_name), which is the dead-letter exchange declared alongside it.

declare_dead_queue(config)

Declares the dead-letter queue (queue_name.dead) with x-message-ttl.

This is an intentionally terminal queue — it has no x-dead-letter-exchange configured. Messages that exceed their TTL here are dropped by the broker rather than routed elsewhere. This prevents infinite retry loops and makes the dead queue a true end-of-line store for unprocessable messages.

To inspect or reprocess dead messages use HareMq.RetryPublisher.republish_dead_messages/2.

declare_delay_queue(config)

Declares the delay queue(s) used by the retry pipeline.

When delay_cascade_in_ms is a non-empty list each delay value gets its own named queue (queue_name.delay.<ms>) with a matching x-message-ttl and dead-letter routing back to the main queue. Otherwise a single queue_name.delay queue is created using delay_in_ms.

declare_queue(config)

Declares a durable RabbitMQ queue (classic or quorum).

declare_stream_queue(config)

Declares a durable RabbitMQ stream queue.

Stream queues are persistent, append-only logs. Messages are not removed after consumption — each consumer maintains its own offset.

The queue is declared with x-queue-type: stream. No exchange binding, delay queue, or dead-letter queue is needed for stream consumers.