0
votes

I have a question about RabbitMQ queue. I would like to send two types of messages on just one queue.

I know that, I can create two different queues, and use routing key to send different messages to different queue.

But I would like to have two consumers on one Queue, and somehow bind Consumer with type of message. It's event's driven via rabbit queue, when client and core are publishers and consumers.

Is it possible, or should I use different Queues?

Data exchange

1
If there are two consumers on one queue, only one of them receives a message. If you need the message to be delivered to both consumers, you need separate queue for each of them. - Petr Aleksandrov
I thought so, but still decided to ask. Wanted to believe, it is somehow possible. Thanks. - Jacek Andrzejczyk
This is a terrible idea, but if you truly HAD to use one queue, you could have some key/check within the Consumer that would NACK the message in order to put it back on the queue. Again, this is not a good choice unless absolutely required. - kendavidson
Smart idea, but I don't truly need one Queue. Just thought that it may be more efficient, than create queue for every consumer. Thanks for your answer, and it's great idea how to solve my problem, but it would be less efficient, so I decided to create many queues. - Jacek Andrzejczyk

1 Answers

0
votes

Like @kendavidson said, there is a possibility to use only one queue, to exchange different messages, but it is terrible idea, because it's not efficient, so you should use it only if it's truly nesesery.

I found comment @Петр Александров useful and I created separate queue for every consumer to fix my problem, and it's something you probably looking for.