Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
use event listener to determine when the consumer has connected
Browse files Browse the repository at this point in the history
  • Loading branch information
fullergalway committed Mar 30, 2016
1 parent 983440a commit 6389c7e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/kafka_ascoltatore.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ KafkaAscoltatore.prototype._startConn = function(cb) {
var newcb = function(){
that._consumerStarting = false;
util.wrap(cb)();
that.emit("consumer.connected");
};
var connectionString = that._opts.connectionString || that._default_opts.connectionString;
var clientId = that._opts.clientId || that._default_opts.clientId;
Expand Down Expand Up @@ -210,7 +211,7 @@ KafkaAscoltatore.prototype.subscribe = function subscribe(topic, callback, done)
var that = this;
if(this._consumerStarting){
debug("waiting for startup before subscribing");
setTimeout(function(){ that.subscribe(topic,callback,done); }, 500);
this.on("consumer.connected",function(){ that.subscribe(topic,callback,done); });
return;
}

Expand Down

0 comments on commit 6389c7e

Please sign in to comment.