Search code examples
rabbitmqrabbitmq-exchange

Some essential question about using RabbitMQ?


After reading documentation about what is Rabbit and what does, I have some common questions:

Case is: Producer sends one message to some consumers (subscribers).

I need a short explanation for all points of list below, what to use, and what to dig further.

  1. How to clear queue and stop sending message to consumers after specific time/date?
  2. Can I include to confirmed message user's data like JSON?
  3. Where is stored this data? In the same queue?
  4. How to filter confirmed messages and then clear queue?
  5. How to clear queue after specific time/date?
  6. What happens if not one consumer no confirms message, how long they are stored?
  7. Does consumer subscribe on queue or can subscribe on exchange too?
  8. Using model one to many for sending message, how to set who have to get message first/last or at the same time, here described that, but not clear is it on client or server side?
  9. If no consumers, how to re-push message to another queue and close current?
  10. Each consumer has own queue?

Thank you in advance and any comment to this question!


Solution

  • If you can elaborate some of your questions and include what is your use case, I can edit the answer.

    1 - As long as consumer is alive rabbitmq sends incoming messages to consumer. You can give TTL to messages/queues if you want them to expire after some time. https://www.rabbitmq.com/ttl.html

    2 - What you mean?

    3 - Rabbitmq stores the data in mnesia database. https://www.rabbitmq.com/persistence-conf.html https://www.rabbitmq.com/relocate.html

    4 - What you mean by filterig messages and clear queue? Successfully consumed messages removed from the queue immediatly.

    5 - You can give ttl to queue or declare queue as auto delete https://www.rabbitmq.com/ttl.html https://www.rabbitmq.com/queues.html

    6 - If consumers don't send ack to rabbit, messages stays unack as long as memory becomes full or rabbit becomes unavailable

    7 - Both. A consumer can create its own queue and bind it to an exchange or it can consume from existing queue. It depends on the use case.

    8 - It is hard to answer this without knowing details of what you mean by one-to-many. Direct exchange or fanout or whatelse, how many queues etc.

    But, in rabbitmq, messages ordered by publish order by default.

    According to link you shared, rabbitmq sends messages first to higher priority consumers until consumer prefetch count (unack messages on consumer) becomes its limits.

    9 - You need to handle this case in the code. Or you can use management ui with Shovel plugin.

    https://www.rabbitmq.com/management.html https://www.rabbitmq.com/shovel.html

    10 - Again, it depends on the design and use case.