Module: AceMQ::AMQP::Naming
- Defined in:
- lib/acemq/amqp/naming.rb
Overview
Where a message goes when it cannot be handled.
Convention rather than protocol, which is exactly why it has to be
identical everywhere: an operator looking for the dead letters of
orders.new should find them in orders.new.dlq whether the consumer
that gave up was written in Java, Go, .NET, Python or Ruby.
Constant Summary collapse
- DEAD_LETTER_SUFFIX =
Where a message goes when every attempt has been used.
".dlq"- PARKED_SUFFIX =
Where a message goes when a person has to look at it.
".parked"- RETRY_EXCHANGE =
The exchange a retry rung dead-letters through on its way back to the queue the message came from.
Written here, once, and read everywhere else. The name is half of the rung's argument table, and that table is a contract between five libraries rather than a preference — see RetryLadder.arguments_for for what depends on it and why a second copy of this string would be a bug nobody sees until two services disagree about a queue.
"acemq.retry"- DEAD_LETTER_EXCHANGE =
The exchange the dead-letter and parking queues are reached through.
Shared with the Java, Go, .NET and Python libraries for the same reason the suffixes are: an operator looking at a broker should see one dead-letter exchange rather than one per language that happened to publish through it.
"acemq.dlx"
Class Method Summary collapse
-
.dead_letter_queue(queue) ⇒ Object
orders.newbecomesorders.new.dlq. -
.parked_queue(queue) ⇒ Object
orders.newbecomesorders.new.parked. -
.retry_queue(queue, delay) ⇒ Object
orders.newand 30 seconds becomeorders.new.retry.30s. -
.short(delay) ⇒ Object
A duration as the shortest thing that reads as one: 30s, 5m, 2h.
Class Method Details
.dead_letter_queue(queue) ⇒ Object
orders.new becomes orders.new.dlq.
51 52 53 |
# File 'lib/acemq/amqp/naming.rb', line 51 def self.dead_letter_queue(queue) queue + DEAD_LETTER_SUFFIX end |
.parked_queue(queue) ⇒ Object
orders.new becomes orders.new.parked.
56 57 58 |
# File 'lib/acemq/amqp/naming.rb', line 56 def self.parked_queue(queue) queue + PARKED_SUFFIX end |
.retry_queue(queue, delay) ⇒ Object
orders.new and 30 seconds become orders.new.retry.30s.
The delay is in the name because a delay queue is per-delay: its
x-message-ttl is fixed at declaration, so a policy with four
different waits needs four queues, and an operator should be able to
tell which is which without reading their arguments.
69 70 71 |
# File 'lib/acemq/amqp/naming.rb', line 69 def self.retry_queue(queue, delay) "#{queue}.retry.#{short(delay)}" end |
.short(delay) ⇒ Object
A duration as the shortest thing that reads as one: 30s, 5m, 2h.
74 75 76 77 78 79 80 81 |
# File 'lib/acemq/amqp/naming.rb', line 74 def self.short(delay) seconds = delay.to_i return "0s" if seconds <= 0 return "#{seconds / 3600}h" if (seconds % 3600).zero? return "#{seconds / 60}m" if (seconds % 60).zero? "#{seconds}s" end |