pub struct RabbitMqOptions {
pub connection_properties: ConnectionProperties,
pub dead_suffix: String,
pub declare_dead_letter_queues: bool,
pub deferred_suffix: String,
pub retry_granularity: Duration,
pub deferred_granularity: Duration,
}Expand description
Configuration for RabbitMqBackend::with_options.
use queuey_rabbitmq::RabbitMqOptions;
let options = RabbitMqOptions::default()
.dead_suffix("-dlq")
.declare_dead_letter_queues(false);
assert_eq!(options.dead_suffix, "-dlq");Fields§
§connection_properties: ConnectionPropertiesHandshake properties passed to lapin::Connection::connect.
dead_suffix: StringSuffix appended to a queue name to name its dead-letter queue.
Defaults to DEFAULT_DEAD_SUFFIX (".dead").
declare_dead_letter_queues: boolWhether declare also declares
the q.dead queues.
Defaults to true. Set to false when dead-letter queues are managed
out of band (policies, an operator-owned topology, a different broker
vhost).
This flag also selects how a message is dead-lettered, because this backend never publishes to a queue it does not own:
true:Delivery::dead_letterpublishes the envelope toq.deadwith thex-death-*headers and then acks the original.false: nothing is published. The original is rejected withrequeue = false, so the broker applies whateverx-dead-letter-exchangepolicy the operator put onq, and drops the message if there is none. The reason is logged atWARN, since it is not recorded anywhere else.
The same choice governs a message whose body is not a valid envelope.
deferred_suffix: StringInfix between a queue name and a hold queue’s TTL.
Defaults to DEFAULT_DEFERRED_SUFFIX (".deferred"), so a 30-second
wait on myapp.emails happens in myapp.emails.deferred.30000. Retries,
delayed enqueues and deferrals all wait in these hold queues; see
crate::topology for why the TTL is part of the name.
retry_granularity: DurationStep that retry backoffs and
Producer::enqueue_after delays
are rounded up to.
Defaults to one second. Every distinct rounded delay gets its own hold queue, so this is the knob that trades backoff precision for the number of queues on the broker. It matters most for exponential backoff with jitter, which produces a different delay for every retry: with the default, a policy capped at five minutes can create at most 300 hold queues per work queue, and a granularity of ten seconds brings that down to 30. Idle hold queues delete themselves, so this bounds the number that exist at once, not a total.
Separate from deferred_granularity on
purpose: a backoff is a heuristic that tolerates coarse rounding, a
Retry-After is a contract that may not.
A retry is never released early: rounding is always up, a delay
shorter than the granularity still waits one full step, and a delay that
rounds up past
MAX_DEFERRAL_MS (~24.8 days) is
refused instead of being shortened. A zero (or sub-millisecond) value is
clamped to one millisecond rather than rejected, exactly as for
deferred_granularity.
deferred_granularity: DurationStep that deferral delays are rounded up to.
Defaults to one second. Every distinct rounded delay gets its own hold
queue, so this is the knob that trades precision for the number of queues
on the broker: with the default, Retry-After: 30 and a computed 29.2s
delay share q.deferred.30000, and no deferral can create more than
MAX_TTL_MS / 1000 queues per work queue.
A deferral is never released early: rounding is always up, a delay
shorter than the granularity still waits one full step, and a delay that
rounds up past
MAX_DEFERRAL_MS (~24.8 days) is
refused instead of being shortened.
A zero (or sub-millisecond) value is clamped to one millisecond by
deferred_ttl_ms rather than
rejected, because a backend constructor must not panic on a config value, but
one millisecond of granularity means up to one hold queue per distinct
millisecond, which is almost never what you want.
Note what is not here: nothing tunes a hold queue’s x-expires. Its
arguments are a pure function of its name (x-expires = 2 * ttl), so two
processes configured differently still agree on q.deferred.30000
instead of locking each other out with PRECONDITION_FAILED. Both
granularities are safe to tune because they only change which hold
queue a delay lands in, never that queue’s arguments.
Implementations§
Source§impl RabbitMqOptions
impl RabbitMqOptions
Sourcepub fn connection_properties(self, properties: ConnectionProperties) -> Self
pub fn connection_properties(self, properties: ConnectionProperties) -> Self
Replace the connection handshake properties.
Sourcepub fn dead_suffix(self, suffix: impl Into<String>) -> Self
pub fn dead_suffix(self, suffix: impl Into<String>) -> Self
Replace the dead-letter queue suffix.
Sourcepub fn declare_dead_letter_queues(self, declare: bool) -> Self
pub fn declare_dead_letter_queues(self, declare: bool) -> Self
Enable or disable declaring q.dead queues.
Sourcepub fn deferred_suffix(self, suffix: impl Into<String>) -> Self
pub fn deferred_suffix(self, suffix: impl Into<String>) -> Self
Replace the hold queue infix.
Sourcepub fn retry_granularity(self, granularity: Duration) -> Self
pub fn retry_granularity(self, granularity: Duration) -> Self
Replace the step retry backoffs and delayed enqueues are rounded up to.
A zero or sub-millisecond value is clamped to one millisecond when the TTL is computed, not rejected here: this is a builder, and library code does not panic on configuration.
Sourcepub fn deferred_granularity(self, granularity: Duration) -> Self
pub fn deferred_granularity(self, granularity: Duration) -> Self
Replace the step deferral delays are rounded up to.
A zero or sub-millisecond value is clamped to one millisecond when the TTL is computed, not rejected here: this is a builder, and library code does not panic on configuration.
Trait Implementations§
Source§impl Clone for RabbitMqOptions
impl Clone for RabbitMqOptions
Source§fn clone(&self) -> RabbitMqOptions
fn clone(&self) -> RabbitMqOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more