Reputation: 87
I'm using rabbitMQ on docker.
When executing the rabbitmq, I want to set the message durability (durable/transient)
.
Is there any way to set up durability? (except when declare Queue and Exchange)
Upvotes: 2
Views: 2143
Reputation: 1906
Yes it is possible to specify delivery-mode message attribute for any published message. However, the target queue must be also durable for a message to be persisted.
See chapter Message Attributes and Payload in RabbitMQ documenation:
Messages in the AMQP model have attributes. Some attributes are so common that the AMQP 0-9-1 specification defines them and application developers do not have to think about the exact attribute name. Some examples are
Content type Content encoding Routing key Delivery mode (persistent or not) Message priority Message publishing timestamp Expiration period Publisher application id
Simply publishing a message to a durable exchange or the fact that the queue(s) it is routed to are durable doesn't make a message persistent: it all depends on persistence mode of the message itself. Publishing messages as persistent affects performance (just like with data stores, durability comes at a certain cost in performance).
Upvotes: 1