What is the "delivery mode" in AMQP?

Amqp

Amqp Problem Overview


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??

Amqp Solutions


Solution 1 - Amqp

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.

Solution 2 - Amqp

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);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjldupontView Question on Stackoverflow
Solution 1 - AmqpalexisView Answer on Stackoverflow
Solution 2 - AmqpGrzegorz MotylView Answer on Stackoverflow