0

I have 2 publish queues and 2 subscribe queues, can I deal with four queues in on connection?

 connection = amqp.createConnection();
 connection.on("ready", function () {
     subscribe(queue1,msg1);
     publishto(queue2,msg1);
     subscribe(queue3,msg2);
     publishto(queue4,msg2);
 }

or four connections?

subscribe1(){
connection = amqp.createConnection();
connection.on("ready", function () {
    subscribeto(queue1,msg1);
    })

subscribe2(){
connection = amqp.createConnection();
connection.on("ready", function () {
    subscribeto(queue1,msg1);
    })
......
nfpyfzyf
  • 2,891
  • 6
  • 26
  • 30

2 Answers2

0

I am not familiar with the node.js setup, but in Java there are connections and channels. I would use 1 connection and 4 channels, with each channel handling 1 queue each.

robthewolf
  • 7,343
  • 3
  • 29
  • 29
0

AMQP is a multiplexed protocol so one connection can handle many subscriptions. Also, it's a lot less resource intensive to utilize channels than creating tons of connections.

Carl Hörberg
  • 5,973
  • 5
  • 41
  • 47