What is the "delivery mode" in AMQP?
Asked Answered
A

3

83

I understand that 2 options are available:

  • "Non-persistent"
  • "Persistent"

But what does this actually mean?

"Non-persistent" as in : the AMQP fabric will try to deliver the message if there are no consumers, the message will be dropped?

"Persistent" as in : AMQP will retry the message until a consumer accepts it??

Allomerism answered 26/2, 2010 at 18:46 Comment(0)
B
77

Messages marked as 'persistent' that are delivered to 'durable' queues will be logged to disk. Durable queues are recovered in the event of a crash, along with any persistent messages they stored prior to the crash.

Bantustan answered 1/3, 2010 at 14:13 Comment(3)
I do not understand why you can declare an Exchange durable. And on the other side you "could"!? declare a queue that "corresponds" to that Exchange nondurable? Or for example if you would declare a Exchange NONDURABLE but a queue durable, and there would be a crash. Could I recover that durable queue in the nondurable exchange? @BantustanViscometer
"durability" only means the Exchange or Queue will survive a server restart.. This does not mean the messages being stored in a durable queue will survive... That would also require a message level property .deliveryMode = 2. (I just tested these cases)Roughhouse
For those who need to check source document , you can find the detail by searching with keyword delivery-mode in AMQP 0.9.1 referenceRibwort
H
24

delivery_mode in AMQP determines if message will be stored on disk after broker restarts. You can mark messages as persistent - by seting delivery_mode property = 2 when you publish message for instance in PHP (PECL AMQP extension):

$exchange->publish($text, $routingKey, null, array('delivery_mode' => 2));

You would also need to declare queue as durable (or it will be dropped after broker stops)

$queue->setFlags(AMQP_DURABLE);
Hitoshi answered 23/8, 2012 at 14:40 Comment(1)
Will the continue to be stored on disk even after they are processed? Or is it only a guarantee that they will be persisted until they get processed?Sublingual
C
0

The value of the delivery mode will tell RabbitMQ if it’s allowed to keep the message in memory when the message is placed in a queue (non-persistent) or if it must store the message on disk first (persistent).

Ceramal answered 21/2, 2023 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.