7

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.

ahj
  • 745
  • 1
  • 6
  • 13

1 Answers1

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 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]
pinepain
  • 12,453
  • 3
  • 60
  • 65
  • 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? – ahj Jul 18 '13 at 10:30
  • Messages will be lost. I updated my answer with example, hope, it will help. – pinepain Jul 18 '13 at 10:32
  • @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? – Ellesedil May 28 '16 at 18:11
  • @Ellesedil 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](https://groups.google.com/forum/#!forum/rabbitmq-users], that's more specific place for such question and RMQ engineers read it and respond there. – pinepain May 28 '16 at 19:18