src/context.js
function consume(exchangeName, topics, handler) {
    // Setup chain
    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.connectExchange(exchangeName, topics, messageHandler);

    // add consume events to status provider
    topics.forEach(function(topic){
        statusProvider.addEventConsume(exchangeName, topic, false);
    });
}
function consume(exchangeName, topics, handler) {
    // Setup chain
    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.connectExchange(exchangeName, topics, messageHandler);

    // add consume events to status provider
    topics.forEach(function(topic){
        statusProvider.addEventConsume(exchangeName, topic, false);
    });
}
function consume ( exchangeName , topics , handler ) { // Setup chain 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 . connectExchange ( exchangeName , topics , messageHandler ) ; // add consume events to status provider topics . forEach ( function ( topic ) { statusProvider . addEventConsume ( exchangeName , topic , false ) ; } ) ; }
Create a consume function for an exchange.

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 handler
Create a consume function for an exchange .