POV
POV

Reputation: 12005

When message will be erased from queue?

Let's suppose we have one producer, one queue and some consumers which are subscribed on queue.

Producer -> Queue -> Consumers

Queues contains messages about life events. These messages should receive all consumers.

When queue will be erased?

  1. When all consumers get message?
  2. Or when one of consumers confirm message with flag ack (true)?

And how to manage priority, who from consumers must to get message first/last (don't confuse with message priority).

As instance I have 10 consumers and I want that the fifth consumer get message first, remaining consumers later after specified time.

Upvotes: 0

Views: 56

Answers (1)

cdelmas
cdelmas

Reputation: 860

Be careful: when there are many consumers on one queue, only one of them will receive a given message, provided that it is consumed and acked properly. You need to bind as many queues as consumers to an exchange to have all consumers receive the message.

For your priority question, there is no built-in mecanism to have consumers receive the same message with a notion of priority: consumer priority exists (see https://www.rabbitmq.com/consumer-priority.html), but it is made to have consumer receive a given message before the others on a given queue, so the other consumers won't receive this message. It you need to orchestrate the delivery of your messages, you have to think of a more complex system (maybe a saga or a resequencer?).

Note that you can delay messages using this pattern. Again, this requires having multiple queues.

Finally, there are many scenarios when a queue is deleted. Take a look at the documentation, these are well explained.

Upvotes: 1

Related Questions