Reputation: 6372
I am using the RabbitMQ java client. My app has multiple exchanges and queues. Adopting something similar to the Pub/Sub model.
What is the best practice regarding connections? Shall I have one connection per app?
I understand the channel model, and the thread (un)safety model. Just not sure if I should have multiple connections or not.
Upvotes: 3
Views: 5177
Reputation: 72858
One connection per app is correct.
Within that connection, you will have many channels - where the actual work is done.
You can have hundreds or thousands of message producers and consumers (each on their on channel) inside a single connection.
If you start to see slowdown in your RMQ setup because you're dong too much work, look at clustering RMQ and/or standing up multiple instances of your app.
But you would still maintain 1 connection per app instance.
Upvotes: 6
Reputation: 1047
It will depends on the volumetry of messages you will have. If it really is huge, maybe 2 or 3 connections could do it, but one per application seems to be the best choice
Upvotes: 1