Skip to main content

deferred_queue_args

Function deferred_queue_args 

Source
pub fn deferred_queue_args(config: &QueueConfig, ttl_ms: u32) -> FieldTable
Expand description

Declaration arguments for the hold queue q.deferred.{ttl_ms}.

  • x-message-ttl = ttl_ms: the delay itself, queue-wide, so the queue drains in publish order.
  • x-dead-letter-exchange = "" plus x-dead-letter-routing-key = q: an expired message goes straight back onto the main queue.
  • x-expires = 2 * ttl_ms: an idle hold queue deletes itself one TTL after the last publish to it, so a delay that never recurs leaves nothing behind. Every declare resets that timer, which is why the queue is redeclared before every publish.

The arguments are a pure function of the hold queue’s name: ttl_ms is in the name, and the routing key and durability come from config, which is the main queue the name is derived from. Nothing here is tunable, on purpose: two processes with different settings would compute different arguments for the same queue name and lock each other out with PRECONDITION_FAILED for ever. See the module docs.

Never carries x-max-priority: a hold queue must stay FIFO, and the priority only matters once the message is back on q.