amqper
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -9,5 +9,5 @@ "use strict"; | ||
console.log('ready'); | ||
client.route('test.a', function (message) { | ||
client.route('test.a', {}, function (message) { | ||
console.log(message.payload); | ||
}); | ||
}); |
@@ -65,7 +65,10 @@ "use strict"; | ||
Client.prototype.publish = function (exchange, routingKey, content) { | ||
var channel = this.channel; | ||
var codec = this.codec; | ||
return when.try(function () { | ||
content = bufferify(codec.encode(content)); | ||
return channel.publish(exchange, routingKey, content); | ||
var that = this; | ||
return this.$promise.then(function () { | ||
var channel = that.channel; | ||
var codec = that.codec; | ||
return when.try(function () { | ||
content = bufferify(codec.encode(content)); | ||
return channel.publish(exchange, routingKey, content); | ||
}); | ||
}); | ||
@@ -87,16 +90,18 @@ }; | ||
var that = this; | ||
var codec = this.codec; | ||
var router = this.context.route(route, options, function (message) { | ||
when.try(function () { | ||
message.payload = codec.decode(message.content); | ||
return handler(message); | ||
}).done(function () { | ||
return message.ack(); | ||
}, function (err) { | ||
debug('error', 'Error thrown in routing handler, not acking message. Error: ', err.stack); | ||
that.emit('error', err); | ||
return this.$promise.then(function () { | ||
var codec = that.codec; | ||
var router = that.context.route(route, options, function (message) { | ||
when.try(function () { | ||
message.payload = codec.decode(message.content); | ||
return handler(message); | ||
}).done(function () { | ||
return message.ack(); | ||
}, function (err) { | ||
debug('error', 'Error thrown in routing handler, not acking message. Error: ', err.stack); | ||
that.emit('error', err); | ||
}); | ||
}); | ||
that.routers.push(router); | ||
return router.$promise; | ||
}); | ||
this.routers.push(router); | ||
return router.$promise; | ||
}; | ||
@@ -103,0 +108,0 @@ |
{ | ||
"name": "amqper", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "A simple and elegant AMQP client for node based on amqplib.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/taoyuan/amqper", |
19744
501