Vor
Vor

Reputation: 35149

Is is possible to setup internal exchange to send messages to the queue, if it's exist?

I have a situation, where I have a RabbitMQ cluster. I have multiple producers, which produce different data. I want each producer to setup a temporary queue based on parameters, and remove the queue if it's empty.

For example producers A and B:

A ----- tmp_a_queue

B ----- tnp_b_queue

I want to do this to scale throughput of the system. Next I want my consumer to create a single queue when it is able to consume, and grab messages from both queues.

For example adding consumer C to above template:

                          _______________________
A ----- tmp_a_queue\     |                       |
                     ====| SOME MAGIC GOES HERE  |-----tmp_c_queue C
B ----- tnp_b_queue/     |_______________________|

I know how to create A,B and C.

Question:

Is is it possible to setup some kind of internal-exchange in such a way that it would grab messages from all of the tmp_queues on the left (Note they come and go dynamically) and send them to the consumer queue (on the right), only if consumer is available?

Upvotes: 1

Views: 567

Answers (1)

cvbarros
cvbarros

Reputation: 1694

You can do that with Shovel plugin if you want the exchange to "consume" the messages. Queues subscribe to exchanges (bind to them), and not otherwise.

Or them you can have a topic exchange. Bind the tmp_queue_c with * and the others with their respective binding keys. But in this scenario, the other queues will still have their messages (they will not be consumed, unless somebody consumes them other than the exchange).

EDIT: I also have found this link on exchange-to-exchange bindings that may prove useful in your case. In that scenario, you would have your normal exchange publishing to tmp_a_queue and tmp_b_queue but another exchange magic bound to the same exchange your 2 first queues are bound to. Then you bind tmp_c_queue to magic exchange and you'll achieve the desired behavior.

Upvotes: 1

Related Questions