pub enum DelayStrategy {
TTL,
DelayedExchange,
}Expand description
Strategy for delaying retry messages
§TTL (Time-To-Live) Strategy
Uses RabbitMQ’s TTL feature with temporary retry queues. Messages are published to temporary queues that expire and route to the original queue. Pros: No plugin required, simple setup Cons: Less precise timing, requires queue cleanup
§DelayedExchange Strategy
Uses the RabbitMQ delayed message exchange plugin (requires x-delayed-message plugin). Messages are published to a delay exchange with x-delay header. The exchange automatically routes messages after the delay period. Pros: More precise, cleaner architecture, single exchange Cons: Requires RabbitMQ plugin installation
§Example
use rust_rabbit::{DelayStrategy, RetryConfig};
use std::time::Duration;
// Using TTL strategy (default, no plugin required)
let config = RetryConfig::exponential_default()
.with_delay_strategy(DelayStrategy::TTL);
// Using RabbitMQ delayed exchange plugin (requires plugin)
let config = RetryConfig::linear(3, Duration::from_secs(5))
.with_delay_strategy(DelayStrategy::DelayedExchange);Variants§
TTL
TTL-based delays using temporary queues (no plugin required)
DelayedExchange
RabbitMQ delayed message exchange plugin (requires x-delayed-message plugin)
IMPORTANT: Using this strategy without the rabbitmq_delayed_message_exchange plugin
will cause your application to crash with “NOT_FOUND - operation not permitted on this exchange” error.
Before deploying code with DelayedExchange, ensure:
- Plugin is installed: https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases
- Plugin is enabled:
rabbitmq-plugins enable rabbitmq_delayed_message_exchange - RabbitMQ is restarted after plugin installation
Trait Implementations§
Source§impl Clone for DelayStrategy
impl Clone for DelayStrategy
Source§fn clone(&self) -> DelayStrategy
fn clone(&self) -> DelayStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more