postwait/node-amqp — Issue #60: Consuming from the same queue can lead to starved consumers
Author: squaremo
Created: 2011-12-30 17:04:00+00:00
State: open

This is a problem resulting from caching queues and hiding channels: message prefetch is defined per channel, but a queue (= one channel) may have more than one consumer. If `queue.subscribe` and the option `autoAck: false` are used, it sets the prefetch to `1`, meaning that another message won't be sent until the previous has been acknowledged.

If there's more than one consumer, then it's easy for one of them to unjustly starve the others by not acknowledging a message. Say, for example, each consumer is piping messages through a stream, and only acknowledging them once the message has successfully written; if the stream is paused, the acknowledgment won't be made, and no other consumer will receive a message either, because they are all sharing the channel and thus the prefetch.

One possible solution to this is to unhide channels, so to allow a channel per consumer. The API as is can be kept as a convenience, and channel exposed for when more fine-grained control is needed. Thoughts? (or would you prefer to wait for a pull request ..)