src/context.js
function consumeShared(exchangeName, topics, queueName, handler, fetchCount = 1) {
    var messageHandler = function(message) {
        // make sure we don't have things like buffers
        message.content = JSON.parse(message.content.toString());

        topics.forEach(function(topic){
            statusProvider.setEventConsumeExample(
                exchangeName,
                topic,
                message.content
            );
        });

        chain(message, handler)
    };

    rabbitmq.connectExchangeSharedQueue(exchangeName, topics, queueName, messageHandler, { prefetch: fetchCount });

    // add consume events to status provider
    topics.forEach(function(topic){
        statusProvider.addEventConsume(exchangeName, topic, true, queueName);
    });
}
function consumeShared(exchangeName, topics, queueName, handler, fetchCount = 1) {
    var messageHandler = function(message) {
        // make sure we don't have things like buffers
        message.content = JSON.parse(message.content.toString());

        topics.forEach(function(topic){
            statusProvider.setEventConsumeExample(
                exchangeName,
                topic,
                message.content
            );
        });

        chain(message, handler)
    };

    rabbitmq.connectExchangeSharedQueue(exchangeName, topics, queueName, messageHandler, { prefetch: fetchCount });

    // add consume events to status provider
    topics.forEach(function(topic){
        statusProvider.addEventConsume(exchangeName, topic, true, queueName);
    });
}
function consumeShared ( exchangeName , topics , queueName , handler , fetchCount = 1 ) { var messageHandler = function ( message ) { // make sure we don't have things like buffers message . content = JSON . parse ( message . content . toString ( ) ) ; topics . forEach ( function ( topic ) { statusProvider . setEventConsumeExample ( exchangeName , topic , message . content ) ; } ) ; chain ( message , handler ) } ; rabbitmq . connectExchangeSharedQueue ( exchangeName , topics , queueName , messageHandler , { prefetch : fetchCount } ) ; // add consume events to status provider topics . forEach ( function ( topic ) { statusProvider . addEventConsume ( exchangeName , topic , true , queueName ) ; } ) ; }
Create a consume function for an exchange using a shared queue. This queue can be used by other workers and the messages
will be shared round-robin.

Handler should return a promise and accept a message. If this is reject promise the message is not acknowledged. If
the resolves it should contain the original message.

@param exchangeName
@param topics
@param queueName
@param handler
@param fetchCount
Create a consume function for an exchange using a shared queue . This queue can be used by other workers and the messages will be shared round - robin .