Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistence and Durability Concepts Confusion in AMQP

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.

like image 849
ahj Avatar asked Jul 18 '13 09:07

ahj


1 Answers

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 sad, 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, your 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]
like image 114
pinepain Avatar answered Sep 29 '22 07:09

pinepain