Skip to content

Message Properties

When you publish, the body — the actual bytes — is only half the story. Every AMQP message also carries a set of properties: metadata that RabbitMQ and your consumers can act on without parsing the body. Some are just informational; a couple genuinely change delivery behaviour.

The property that changes behaviour: delivery_mode

Section titled “The property that changes behaviour: delivery_mode”

The one property that affects reliability is delivery_mode (also called “persistent”):

  • delivery_mode = 2 (persistent) — RabbitMQ writes the message to disk, so it can survive a broker restart.
  • delivery_mode = 1 (transient, the default in raw AMQP) — the message lives in memory and is lost on restart.

Pair this with a durable queue (last lesson). The rule is worth memorising: durable queue + persistent message = survives a restart. Miss either half and the data is at risk.

Persistence isn’t free — writing to disk costs throughput. That’s a real trade-off you’ll weigh in the reliability module.

The rest describe the message so consumers (and tooling) can handle it correctly:

PropertyPurpose
content_typee.g. application/json — how to interpret the body
content_encodinge.g. gzip
headersArbitrary key/value metadata (also used by the headers exchange)
correlation_idMatch a reply to its request (the RPC pattern)
reply_toThe queue a reply should be sent to
message_idA unique id — handy for idempotency and deduplication
timestampWhen the message was created
priorityHigher-priority messages jump the queue (needs a priority queue)
expirationPer-message TTL in milliseconds
channel.publish('orders', 'order.created', Buffer.from(JSON.stringify(order)), {
persistent: true, // delivery_mode = 2
contentType: 'application/json',
messageId: order.id,
timestamp: Date.now(),
headers: { source: 'checkout' },
});
Which message property actually affects whether a message survives a broker restart?
What combination is required for a message to survive a restart?
What is the cost of publishing persistent messages?
Which property pair is used to correlate a reply with its request in the RPC pattern?