Persistence and Durability Concepts Confusion in AMQP
Asked Answered
G

1

8

Being a bit confused about these two terms, I'm thinking what is the purpose of having a persistent message but transient (non-durable) queue? After all, if the broker restarts and the queues are not restored the recovered messages will be wasted.

Gebhart answered 18/7, 2013 at 9:27 Comment(0)
W
4

You can have durable queue, but "mortal" messages, so after broker restarts you can still have queue but it will be empty and vice versa, but as you said, yes, you'll lose all messages in the queue.

In the combination you provided message persistence option is really useless but will cause no error.

But if you bind alternate exchange to exchange you are publishing messages to and it is durable, after restart, you can route messages to it if you don't have transient queue declared.

Example:

Assume we have such combination and properly bound queues, Q*1 receive messages M*1 and Q*2 - M*2.

[    Exchange-main/durable   ] + [Exchange-alternate/durable]
[Qm1/transient][Qm2/transient]   [Qax1/durable][Qax2/durable]

Let's publish messages [Mt1/transient] and `[Md1/durable], we'll get such situation:

[    Exchange-main/durable   ] + [Exchange-alternate/durable]
[Qm1/transient][Qm2/transient]   [Qax1/durable][Qax2/durable]
[Mt1/transient]
[Md1/durable]

After restart we'll get

[    Exchange-main/durable   ] + [Exchange-alternate/durable]
                                 [Qax1/durable][Qax2/durable]

Let's publish two messages again, [Mt1/transient] and [Md1/durable]:

[    Exchange-main/durable   ] + [Exchange-alternate/durable]
                                 [Qax1/durable][Qax2/durable]
                                 [Mt1/transient]
                                 [Md1/durable]

So, restart broker again:

[    Exchange-main/durable   ] + [Exchange-alternate/durable]
                                 [Qax1/durable][Qax2/durable]
                                 [Md1/durable]
Willowwillowy answered 18/7, 2013 at 10:15 Comment(4)
So when in in vice versa scenario we have "mortal" queues and persistent messages, after restart we will end up with no queues but messages that were assigned previously to the no more existing queues, does that mean we have dangling messages?Gebhart
Messages will be lost. I updated my answer with example, hope, it will help.Willowwillowy
@pinepain: Define "messages will be lost." Does that mean that messages have been deleted from the disk, or that they're still on the disk but have been orphaned because RabbitMQ no longer knows where they are?Roadwork
@Roadwork can't answer exactly what happens under the hood, but you shouldn't rely on a situation when some messages that were persisted to disk still physically there. With extensive messages flow that even highly unlikely. For more detailed answer you may search through [RabbitMQ official user group](groups.google.com/forum/#!forum/rabbitmq-users], that's more specific place for such question and RMQ engineers read it and respond there.Willowwillowy

© 2022 - 2024 — McMap. All rights reserved.