lib/createWorkers.js
function _getMessageConsumer(channel, handle, validate, routingKey) {
    return function* _consumeMessage(message) {
      try {
        logger.debug({ message, routingKey }, '[worker#listen] received message');

        const content = _parseMessage(message);
        if (!content) return channel.ack(message);

        const validatedContent = _validateMessage(validate, content);
        if (_.isError(validatedContent)) return channel.ack(message);

        const handleSuccess = yield _handleMessage(
          handle,
          validatedContent || content,
          message.fields
        );
        if (!handleSuccess) return channel.nack(message);
        return channel.ack(message);
      } catch (err) {
        logger.error({ err, routingKey }, '[worker#listen] failed to ack/nack');
        return null;
      }
    };
  }
function _getMessageConsumer(channel, handle, validate, routingKey) {
    return function* _consumeMessage(message) {
      try {
        logger.debug({ message, routingKey }, '[worker#listen] received message');

        const content = _parseMessage(message);
        if (!content) return channel.ack(message);

        const validatedContent = _validateMessage(validate, content);
        if (_.isError(validatedContent)) return channel.ack(message);

        const handleSuccess = yield _handleMessage(
          handle,
          validatedContent || content,
          message.fields
        );
        if (!handleSuccess) return channel.nack(message);
        return channel.ack(message);
      } catch (err) {
        logger.error({ err, routingKey }, '[worker#listen] failed to ack/nack');
        return null;
      }
    };
  }
function _getMessageConsumer ( channel , handle , validate , routingKey ) { return function * _consumeMessage ( message ) { try { logger . debug ( { message , routingKey } , '[worker#listen] received message' ) ; const content = _parseMessage ( message ) ; if ( ! content ) return channel . ack ( message ) ; const validatedContent = _validateMessage ( validate , content ) ; if ( _ . isError ( validatedContent ) ) return channel . ack ( message ) ; const handleSuccess = yield _handleMessage ( handle , validatedContent || content , message . fields ) ; if ( ! handleSuccess ) return channel . nack ( message ) ; return channel . ack ( message ) ; } catch ( err ) { logger . error ( { err , routingKey } , '[worker#listen] failed to ack/nack' ) ; return null ; } } ; }
Create an AMQP message consumer with the given handler

@param {Object} channel The AMQP channel.
@param {function} handle the message handler
@param {function} validate the message validator
@returns {function} The generator function that consumes an AMQP message
@param {String} routingKey routing key to bind on
@private
Create an AMQP message consumer with the given handler