5.7. Durable Queues and Durable Messages in C++

By default, the message queue will remain active in the broker as long as the broker is running, even though the program that created the queue has terminated. Should the broker crash, however, the queue and any messages would be lost. In order to avoid accidental loss as a result of machine failure, both queues and messages can be made durable.
If a queue is durable, the queue survives a server crash, as well as any durable messages that have been placed on the queue (non-durable messages on a durable queue may be lost if the server crashes). However, a queue may also be declared autoDelete, which means the queue is deleted automatically when the last client unsubscribes to the queue or terminates. If a queue is both durable and autoDelete, it is still deleted when the last client unsubscribes or terminates. To make a queue durable, specify durable=true when you declare the queue:
session.queueDeclare(arg::queue=name, arg::durable=true);
To make a message durable, set the delivery mode for the message to PERSISTENT: