rabbitmq

corneliu edited this page Jul 23, 2013 · 4 revisions

Rabbitmq wrapper adaptor over node-amqp

config

[...]
/**
 * Boot modules
 */
,boot : {        
    /**
     * rabbitMq configuration
     */
    , queue : [ 'rabbit' , { host : '1.2.3.4' , port : '5672' } ]
[...]

fetch connection

this.kernel . queue ( callback : function (err, connection) )

queue object

conn . queue ( queue : string, document : object, callback : function (err) )

[...]
this.kernel.queue(function(err, conn) {
    conn.queue('test-queue', { id : 12345, data : 'test'} , function(err) {
        console.log(err);
    });
});
[...]

subscribe to queue

conn . subscribe ( queue : string, callbackreceive : function (err, obj) , callbacksubscribe : function (response) )

[...]
this.kernel.queue(function(err, conn) {
    conn.subscribe('test-queue', 
        function (err, obj) {
            if (!err) {
                console.log('Received message : ' + obj);
            }
        },
        function (response) {
            console.log('Subscribed to queue, response : ' + response);
        },
    );
});
[...]