Skip to content

AMQP Binding

The AMQP binding maps OJS operations to AMQP 0-9-1 primitives, enabling OJS backends built on RabbitMQ, Azure Service Bus, and other AMQP-compatible message brokers.

Producer → Direct Exchange → Queue (ojs.queue.{name})
→ DLX → Dead Letter Queue (ojs.dead.{name})
→ Retry Exchange → Delay Queues (TTL-based)
ComponentNameTypeDescription
Job exchangeojs.directDirectRoutes jobs to queues by routing key
Job queueojs.queue.{name}ClassicPer-queue job storage
Dead letter exchangeojs.dlxDirectRoutes dead letter jobs
Dead letter queueojs.dead.{name}ClassicPer-queue dead letter storage
Retry exchangeojs.retryDirectRoutes jobs to delay queues
OJS OperationAMQP PrimitiveDetails
PUSH (enqueue)Basic.PublishPublish to ojs.direct with routing key = queue name
FETCH (dequeue)Basic.ConsumeConsume from ojs.queue.{name} with manual ack
ACKBasic.AckAcknowledge successful processing
FAIL (retryable)Basic.Nack + republishNack and publish to retry exchange with delay
FAIL (terminal)Basic.NackNack without requeue; routes to DLX
CANCELBasic.NackNack without requeue
AMQP PropertyOJS FieldDescription
message_ididJob ID (UUIDv7)
typetypeJob type
content_typeapplication/openjobspec+json
delivery_mode2 (persistent)
prioritypriorityAMQP priority (0–9 mapped from OJS priority)
timestampcreated_atJob creation time
expirationenqueue_ttlMessage TTL in milliseconds

OJS metadata is stored in AMQP headers with the x-ojs- prefix:

HeaderDescription
x-ojs-attemptCurrent attempt number
x-ojs-queueOriginal queue name
x-ojs-scheduled-atScheduled execution time
x-ojs-traceparentW3C Trace Context

Retries use dead letter exchanges with TTL-based delay queues:

  1. Worker nacks the message with requeue: false
  2. Message routes to the retry exchange via DLX configuration
  3. Retry exchange routes to a delay queue with the appropriate TTL
  4. After TTL expires, the message is re-routed to the original queue

For backends using the RabbitMQ Delayed Message Exchange plugin, a single exchange with per-message delay headers can replace the TTL queue chain.

  • Connection pooling: One connection per application, multiple channels.
  • Channel-per-thread: Each worker thread uses its own channel.
  • Reconnection: Exponential backoff with jitter on connection loss.
  • Heartbeat: AMQP heartbeat interval of 60 seconds recommended.
  • W3C Trace Context propagated via x-ojs-traceparent header.
  • Metrics exported for publish rate, consume rate, ack/nack counts, and queue depth.
  • RabbitMQ management plugin provides additional monitoring.