RabbitMQ 耐久性

RabbitMQ Durability

我在 docker 上使用 rabbitMQ。
执行rabbitmq时,我想设置消息持久性(durable/transient).
有没有办法设置耐久性? (声明队列和交换时除外)

是的,可以为任何已发布的消息指定 传递模式 消息属性。但是,目标队列也必须持久才能持久保存消息。

请参阅 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).