rhea/rhea.js
function amqpResponderNode(config) {

        RED.nodes.createNode(this, config);

        // get endpoint configuration
        this.endpoint = RED.nodes.getNode(config.endpoint);
        // get all other configuration
        this.address = config.address;

        var node = this;
        // node not yet connected
        this.status({ fill: 'red', shape: 'dot', text: 'disconnected' });

        if (this.endpoint) {

            node.endpoint.connect(function(connection) {
                setup(connection);
            });

            /**
             * Node setup for creating receiver link for receiving the request
             * and the sender for sending reply
             *
             * @param connection    Connection instance
             */
            function setup(connection) {

                var request = undefined;
                var reply_to = undefined;
                var response = undefined;

                node.connection = connection;

                // node connected
                node.status({ fill: 'green', shape: 'dot', text: 'connected' });

                node.sender = node.connection.open_sender({ target: {} });

                // build receiver options
                var receiver_options = {
                    source: {
                        address: node.address
                    }
                };
                node.receiver = node.connection.open_receiver(receiver_options);

                node.receiver.on('message', function(context) {

                    // save request and reply_to address on AMQP message received
                    request = context.message;
                    reply_to = request.reply_to;

                    // provides the request and delivery as node output
                    var msg = {
                        payload: context.message,
                        delivery: context.delivery
                    };
                    node.send(msg);
                });

                node.connection.on('disconnected', function(context) {
                    // node disconnected
                    node.status({fill: 'red', shape: 'dot', text: 'disconnected' });
                });

                node.on('input', function(msg) {
                    // enough credits to send
                    if (node.sender.sendable()) {

                        if (reply_to) {

                            // fill the response with the provided one as input
                            response = msg.payload;
                            response.to = reply_to;

                            node.sender.send(response);
                        }
                    }
                });

                node.on('close', function() {
                    if (node.sender != null)
                        node.sender.detach();
                    if (node.receiver != null)
                        node.receiver.detach();
                    node.connection.close();
                })

            }

        }
    }
function amqpResponderNode(config) {

        RED.nodes.createNode(this, config);

        // get endpoint configuration
        this.endpoint = RED.nodes.getNode(config.endpoint);
        // get all other configuration
        this.address = config.address;

        var node = this;
        // node not yet connected
        this.status({ fill: 'red', shape: 'dot', text: 'disconnected' });

        if (this.endpoint) {

            node.endpoint.connect(function(connection) {
                setup(connection);
            });

            /**
             * Node setup for creating receiver link for receiving the request
             * and the sender for sending reply
             *
             * @param connection    Connection instance
             */
            function setup(connection) {

                var request = undefined;
                var reply_to = undefined;
                var response = undefined;

                node.connection = connection;

                // node connected
                node.status({ fill: 'green', shape: 'dot', text: 'connected' });

                node.sender = node.connection.open_sender({ target: {} });

                // build receiver options
                var receiver_options = {
                    source: {
                        address: node.address
                    }
                };
                node.receiver = node.connection.open_receiver(receiver_options);

                node.receiver.on('message', function(context) {

                    // save request and reply_to address on AMQP message received
                    request = context.message;
                    reply_to = request.reply_to;

                    // provides the request and delivery as node output
                    var msg = {
                        payload: context.message,
                        delivery: context.delivery
                    };
                    node.send(msg);
                });

                node.connection.on('disconnected', function(context) {
                    // node disconnected
                    node.status({fill: 'red', shape: 'dot', text: 'disconnected' });
                });

                node.on('input', function(msg) {
                    // enough credits to send
                    if (node.sender.sendable()) {

                        if (reply_to) {

                            // fill the response with the provided one as input
                            response = msg.payload;
                            response.to = reply_to;

                            node.sender.send(response);
                        }
                    }
                });

                node.on('close', function() {
                    if (node.sender != null)
                        node.sender.detach();
                    if (node.receiver != null)
                        node.receiver.detach();
                    node.connection.close();
                })

            }

        }
    }
function amqpResponderNode ( config ) { RED . nodes . createNode ( this , config ) ; // get endpoint configuration this . endpoint = RED . nodes . getNode ( config . endpoint ) ; // get all other configuration this . address = config . address ; var node = this ; // node not yet connected this . status ( { fill : 'red' , shape : 'dot' , text : 'disconnected' } ) ; if ( this . endpoint ) { node . endpoint . connect ( function ( connection ) { setup ( connection ) ; } ) ; /**
             * Node setup for creating receiver link for receiving the request
             * and the sender for sending reply
             *
             * @param connection    Connection instance
             */ function setup ( connection ) { var request = undefined ; var reply_to = undefined ; var response = undefined ; node . connection = connection ; // node connected node . status ( { fill : 'green' , shape : 'dot' , text : 'connected' } ) ; node . sender = node . connection . open_sender ( { target : { } } ) ; // build receiver options var receiver_options = { source : { address : node . address } } ; node . receiver = node . connection . open_receiver ( receiver_options ) ; node . receiver . on ( 'message' , function ( context ) { // save request and reply_to address on AMQP message received request = context . message ; reply_to = request . reply_to ; // provides the request and delivery as node output var msg = { payload : context . message , delivery : context . delivery } ; node . send ( msg ) ; } ) ; node . connection . on ( 'disconnected' , function ( context ) { // node disconnected node . status ( { fill : 'red' , shape : 'dot' , text : 'disconnected' } ) ; } ) ; node . on ( 'input' , function ( msg ) { // enough credits to send if ( node . sender . sendable ( ) ) { if ( reply_to ) { // fill the response with the provided one as input response = msg . payload ; response . to = reply_to ; node . sender . send ( response ) ; } } } ) ; node . on ( 'close' , function ( ) { if ( node . sender != null ) node . sender . detach ( ) ; if ( node . receiver != null ) node . receiver . detach ( ) ; node . connection . close ( ) ; } ) } } }
Node for AMQP responder
Node for AMQP responder