pub struct RabbitMqProvider { /* private fields */ }Expand description
RabbitMQ queue provider using AMQP 0-9-1 via the lapin crate.
All queues are declared as durable on first use. Messages are published with
delivery_mode = 2 (persistent) so they survive broker restarts.
The provider emulates visibility timeouts by keeping in-flight messages in an
unacked state on the AMQP broker. If the application crashes before calling
[complete_message] or [abandon_message], the AMQP broker will redeliver
the message once the connection is dropped.
§Channel Strategy
A single persistent AMQP channel is reused for all publish operations and a second for all receive operations instead of opening a new channel per call. Both channels are recreated transparently if the broker closes them. This keeps the channel count bounded regardless of message throughput and avoids exhausting the broker’s per-connection channel limit.
Implementations§
Source§impl RabbitMqProvider
impl RabbitMqProvider
Sourcepub async fn new(config: RabbitMqConfig) -> Result<Self, RabbitMqError>
pub async fn new(config: RabbitMqConfig) -> Result<Self, RabbitMqError>
Create a new RabbitMqProvider and establish an AMQP connection.
§Errors
Returns RabbitMqError if the AMQP connection cannot be established or
if the URL is malformed.
§Examples
use queue_runtime::providers::RabbitMqProvider;
use queue_runtime::RabbitMqConfig;
let config = RabbitMqConfig::default();
let provider = RabbitMqProvider::new(config).await.unwrap();