lib/createWorkers.js
function _subscribeToChannelEvents(channel,
    { exchangeName, queueName, channelPrefetch, workerName }) {
    channel.on('error', err => {
      logger.error(
        { err, exchangeName, queueName, channelPrefetch, workerName },
        '[AMQP] channel error'
      );
    });
    channel.on('close', () => {
      logger.info(
        { exchangeName, queueName, channelPrefetch, workerName },
        '[AMQP] channel closed'
      );
      // Remove this channel because is closed
      workerChannels.delete(channel);
      workers.close();
    });
  }
function _subscribeToChannelEvents(channel,
    { exchangeName, queueName, channelPrefetch, workerName }) {
    channel.on('error', err => {
      logger.error(
        { err, exchangeName, queueName, channelPrefetch, workerName },
        '[AMQP] channel error'
      );
    });
    channel.on('close', () => {
      logger.info(
        { exchangeName, queueName, channelPrefetch, workerName },
        '[AMQP] channel closed'
      );
      // Remove this channel because is closed
      workerChannels.delete(channel);
      workers.close();
    });
  }
function _subscribeToChannelEvents ( channel , { exchangeName , queueName , channelPrefetch , workerName } ) { channel . on ( 'error' , err => { logger . error ( { err , exchangeName , queueName , channelPrefetch , workerName } , '[AMQP] channel error' ) ; } ) ; channel . on ( 'close' , ( ) => { logger . info ( { exchangeName , queueName , channelPrefetch , workerName } , '[AMQP] channel closed' ) ; // Remove this channel because is closed workerChannels . delete ( channel ) ; workers . close ( ) ; } ) ; }
Bind a logger to noticeable channel events
@param {Object} channel the channel object
@param {String} exchangeName the exchange name to use
@param {String} queueName the queue name to target
@param {Number} channelPrefetch number of message to prefetch from channel
@param {String} workerName the name of the worker (for logs)
@returns {*} -
@private
Bind a logger to noticeable channel events