How to use stompit.ChannelPool to manage STOMP channels
masterThe stompit.ChannelPool class manages a pool of STOMP channels to optimize connection reuse and limit concurrent channel allocation. Instead of manually managing connections, you request a channel from the pool, perform your operations (send/subscribe), and the pool handles the lifecycle based on idle events.
Requesting a channel
Use channelPool.channel(callback) to request an unused channel. The channel is passed to the callback as the second argument.
Important Lifecycle Note: The pool determines if a channel is available for reuse or should be closed based on the idle event. This event is emitted when all send and subscribe operations on that channel are completed. If you perform a single send operation and no other operations are active, the channel will immediately emit idle and may be returned to the pool or closed.
channelPool.channel(function(error, channel) {
// Use the channel here
});