When using RabbitMQ for sending messages you basically have exchanges, queues and bindings. I've understood their idea and how they relate to each other, but I am not quite sure who sets up what.
Basically, I have three scenarios in my application.
What I want to achieve is one component that sends messages to a queue, and there shall be several worker processes that handle items in that queue. This seems quite easy to me. The setup is as follows:
Whenever a message is sent to the exchange, it gets delivered to the queue, and the worker processes get their tasks.
Everything shall be durable.
So who sets up what? In my opinion:
Right?
The second scenario is quite different. Basically, it's a pub / sub scenario where each message is send to every currently listening client. If a client goes offline, it does not receive messages any longer and they are not stored anywhere for him. This means the following setup:
So who sets up what? In my opinion:
Right?
Basically the same as scenario 2, but the messages should not be lost if a consumer goes offline. In my opinion this should not change anything - right?
Server-named Queues In AMQP 0-9-1, the broker can generate a unique queue name on behalf of an app. To use this feature, pass an empty string as the queue name argument: The same generated name may be obtained by subsequent methods in the same channel by using the empty string where a queue name is expected.
Exchanges are message routing agents, defined by the virtual host within RabbitMQ. An exchange is responsible for routing the messages to different queues with the help of header attributes, bindings, and routing keys. A binding is a "link" that you set up to bind a queue to an exchange.
In actual case, working of RabbitMQ is that producer sends message to “EXCHANGE” and exchange pushes it to multiple queues and workers get message from queues to which it has binded with. Now instead of publishing directly to queue, producer now publish messages to exchange.
I think what you say is right except on Scenario 3.
If messages should not be lost if a consumer goes offline then you need durable queues and the queues can't be auto_delete'd.
Everything else seems right to me.
In the case of scenario 2 you could also let RabbitMQ auto-generate queue names for you and then let those queues be auto-delete'd once the consumer disconnects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With