arobson / rabbot

Deprecated: Please see https://github.com/Foo-Foo-MQ/foo-foo-mq
MIT License
277 stars 129 forks source link

Handle and subscribe to multiple queues in one channel #134

Closed Gittekken closed 6 years ago

Gittekken commented 6 years ago

Hi, I was wondering how to go about handling and subscribing to multiple queues under one channel? With “rabbit.handle” and “rabbit.startSubscription” I am able to handle and subscribe to one queue per channel but I was wondering if it was possible to do this all under one channel?

In amqplib, I can use ch.consume and it would consume from multiple queues under one channel. For example Ch.consume(queue1) Ch.consume(queue3) Ch.consume(queue5)

Thanks Ken

arobson commented 6 years ago

@gittekken - by design you cannot do this. There’s no reason to that I’m aware of. AMQP is a multiplexing protocol and typically it’s better to separate operations per queue to a channel especially because any issues on the channel would close it and disrupt all consumers on the channel. In cases where you’re using acks (and especially batching acknowledgements) - losing a channel that was consuming multiple queues would mean having to clean up several sets of messages in various states.

All that said - if you want to micromanage channels, Rabbot is not the library you want. I intentionally design it to hide channel operations and manage them all for you. You’ll be much happier just using amqlib which exposes the entire protocol primitives directly.