exp-amqp-connection
Advanced tools
Comparing version
@@ -57,2 +57,5 @@ "use strict"; | ||
var exchange = null; | ||
connectionConfig.clientProperties = | ||
{"capabilities": {"consumer_cancel_notify": !!behaviour.consumerCancelNotification}}; | ||
var conn = amqp.createConnection(connectionConfig); | ||
@@ -137,2 +140,5 @@ | ||
}); | ||
queue.on("basicCancel", function () { | ||
handleError("Subscription cancelled from server side", onExclusiveCallback, logger); | ||
}); | ||
queue.on("error", function (err) { | ||
@@ -167,2 +173,5 @@ if (err.code === 403) { | ||
queue.once("basicConsumeOk", function () {return actualSubscribeCallback(); }); | ||
queue.on("basicCancel", function () { | ||
handleError("Subscription cancelled from server side", actualSubscribeCallback, logger); | ||
}); | ||
queue.bind(behaviour.exchange, routingKey); | ||
@@ -169,0 +178,0 @@ queue.subscribe(subscribeOptions, handler); |
{ | ||
"name": "exp-amqp-connection", | ||
"description": "Wrapper for amqp lib that adds some nice features", | ||
"author": "AB Kvällstidningen Expressen", | ||
@@ -9,3 +10,3 @@ "contributors": [ | ||
], | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"scripts": { | ||
@@ -12,0 +13,0 @@ "test": "NODE_ENV=test mocha -t 5000 && jshint ." |
@@ -41,7 +41,10 @@ # Simple amqp library | ||
subscribeOptions: "...", // Options to use for subscribing, | ||
consumerCancelNotification: "..." // If true, enable rabbit consumner cancel notifications. Causes exit of dieOnError is set, otherwise the notification will just be logged | ||
}; | ||
``` | ||
default values for options, these will be merged with your changes. | ||
More info om consumer cancel notifications here: http://www.rabbitmq.com/consumer-cancel.html | ||
Default values for options, these will be merged with your changes: | ||
```javascript | ||
@@ -75,6 +78,9 @@ var defaultExchangeOptions = { | ||
NOTE: it is highly recommended to enable both ``dieOnError`` as well as ``consumerCancelNotification`` when subscribing | ||
to ensure a restart/reconnect in all scenarios where the subscription fails. | ||
```js | ||
var amqpConn = require("exp-amqp-connection"); | ||
amqpConn({host: "amqpHost"}, {exchange: "myExchange"}, function (err, conn) { | ||
var behaviour = {exchange: "myExchange", dieOnError: true, consumerCancelNotification: true}; | ||
amqpConn({host: "amqpHost"}, behaviour, function (err, conn) { | ||
if (err) return console.err(err); | ||
@@ -81,0 +87,0 @@ conn.subscribe("myRoutingKey", "myQueueName", function (message, headers, deliveryInfo, messageObject) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
31
6.9%442
4.74%154
4.05%76997
-4.91%