pub struct RabbitMqOptions {
pub connection_properties: ConnectionProperties,
pub retry_suffix: String,
pub dead_suffix: String,
pub declare_dead_letter_queues: bool,
pub deferred_suffix: String,
pub deferred_granularity: Duration,
}Expand description
Configuration for RabbitMqBackend::with_options.
use queuey_rabbitmq::RabbitMqOptions;
let options = RabbitMqOptions::default()
.retry_suffix("-wait")
.dead_suffix("-dlq")
.declare_dead_letter_queues(false);
assert_eq!(options.retry_suffix, "-wait");Fields§
§connection_properties: ConnectionPropertiesHandshake properties passed to lapin::Connection::connect.
retry_suffix: StringSuffix appended to a queue name to name its retry (wait) queue.
Defaults to DEFAULT_RETRY_SUFFIX (".retry").
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
deferral of myapp.emails waits in myapp.emails.deferred.30000. See
crate::topology for why the TTL is part of the name.
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. The
granularity is safe to tune because it only changes 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 retry_suffix(self, suffix: impl Into<String>) -> Self
pub fn retry_suffix(self, suffix: impl Into<String>) -> Self
Replace the retry queue suffix.
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 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