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::retry::{DelayStrategy, RetryConfig, RetryMechanism};
use std::time::Duration;
// Using TTL strategy (default, no plugin required)
let config = RetryConfig {
max_retries: 3,
mechanism: RetryMechanism::Exponential {
base_delay: Duration::from_secs(1),
max_delay: Duration::from_secs(60),
},
delay_strategy: DelayStrategy::TTL,
dead_letter_exchange: None,
dead_letter_queue: None,
};
// Using RabbitMQ delayed exchange plugin (requires plugin)
let config = RetryConfig {
max_retries: 3,
mechanism: RetryMechanism::Linear { delay: Duration::from_secs(5) },
delay_strategy: DelayStrategy::DelayedExchange,
dead_letter_exchange: None,
dead_letter_queue: None,
};Variants§
TTL
TTL-based delays using temporary queues (no plugin required)
DelayedExchange
RabbitMQ delayed message exchange plugin (requires x-delayed-message plugin)
Trait Implementations§
Source§impl Clone for DelayStrategy
impl Clone for DelayStrategy
Source§fn clone(&self) -> DelayStrategy
fn clone(&self) -> DelayStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DelayStrategy
impl Debug for DelayStrategy
Source§impl Default for DelayStrategy
impl Default for DelayStrategy
Source§impl<'de> Deserialize<'de> for DelayStrategy
impl<'de> Deserialize<'de> for DelayStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for DelayStrategy
impl Serialize for DelayStrategy
impl Copy for DelayStrategy
Auto Trait Implementations§
impl Freeze for DelayStrategy
impl RefUnwindSafe for DelayStrategy
impl Send for DelayStrategy
impl Sync for DelayStrategy
impl Unpin for DelayStrategy
impl UnwindSafe for DelayStrategy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more