mxriverlynn / rabbus

A micro-service bus with built-in messaging patterns, for NodeJS and RabbitMQ
116 stars 26 forks source link

ack not working on wascally v0.2.2 but it works on v0.2.0-8 #6

Closed gideonairex closed 8 years ago

gideonairex commented 9 years ago

I have tested rabbus and wascally using the latest version which is v0.2.2 then I found out that it doesnt acknowledge messages. But it works on v0.2.0-8. I I think there is something wrong with the new wascally version or are there changes that needs to changed on rabbus?

mxriverlynn commented 9 years ago

Can you post your test code? I'm using Rabbus w/ Wacally v0.2.2 and am not seeing this issue. There may be something I'm doing that I don't realize, or perhaps it's a timing thing with connection being closed prior to the message making it through the exchange? Sample code to reproduce the issue would help a lot.

gideonairex commented 9 years ago

Here are my codes. I am using the Request-Reponse pattern.

Environments:

  1. Non-working environment
    • wascally v0.2.2
    • rabbus v0.2.4
  2. Working environment
    • wascally v0.2.0-8
    • rabbus v0.2.4

Requester

'use strict';

var util   = require( 'util' );
var Rabbit = require( 'wascally' );
var Rabbus = require( 'rabbus' );

Rabbit.configure( {
    'connection' : {
        'server' : 'localhost',
        'port'   : 15672,
        'vhost'  : '/',
        'user'   : 'guest',
        'pass'   : 'guest'
    }
} ).then ( function () {

  function Requester ( rabbus ){

        Rabbus.Requester.call( this, rabbus, {
            exchange    : 'req-res.testing-exchange',
            messageType : 'req-res.v1.testing.test'
        } );

    }

    util.inherits( Requester, Rabbus.Requester );
    var requester = new Requester( Rabbit );

    var msg = {
        'message' : 'This is a message'
    };

    requester.request( msg, function( response, done ){

        console.log( arguments );
        console.log( response );
        done();
        // done is not present on the arguments

    } );

} );

Responder

'use strict';

var util   = require( 'util' );
var Rabbit = require( 'wascally' );
var Rabbus = require( 'rabbus' );

Rabbit.configure( {
    'connection' : {
        'server' : 'localhost',
        'port'   : 15672,
        'vhost'  : '/',
        'user'   : 'guest',
        'pass'   : 'guest'
    }
} ).then ( function () {

  function Responder ( rabbus ){

        Rabbus.Responder.call( this, rabbus, {
            exchange    : "req-res.testing-exchange",
            messageType : "req-res.v1.testing.test",
            queue       : "req-res.testing-queue"
        } );

    }

    util.inherits( Responder, Rabbus.Responder );
    var responder = new Responder( Rabbit );

    responder.handle( function ( message, reply ){

        console.log( arguments );
        console.log( message );

        reply( {
            'message' : 'I got this'
        } );

    } );

} );

Non-working environment

Results

Running on non-working environment it results to the following:

  1. Ready | 0 msg
  2. Unacked | 1 msg
  3. Total | 1 msg

It does not acknowledge the message and done is not present on the callback of the requester. I checked your Rabbus library code and even if I put a message.ack() or even with the forceAck option it still doesn't acknowledge those messages. I found it when I was benchmarking my node using ab and noticed that it doesn't acknowledge those messages. It results to crashing the rabbitmq with increasing memory usage. I also waited maybe it was just delayed acknowledgement but still didnt acknowledge it.

Working environment

Results

Running on working environment it results to the following:

  1. Ready | 0 msg
  2. Unacked | 0 msg
  3. Total | 0 msg

It works when I changed the version of wascally to v0.2.0-8

BLaurent commented 9 years ago

Hi, Try without this one: requester.request(msg, function (response) { console.log("Hello", response.place); });

the promise is rejected because of done being undefined and the ack is indeed not done.

mxriverlynn commented 8 years ago

this should be resolved by now, with newer wascally and rabbus releases