@techloop/amqp-broker
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -31,3 +31,3 @@ if (!process.env.EXCHANGE_NAME) { | ||
onQueueOpen(q, failed_q) { | ||
onQueueOpen(q) { | ||
console.log(`Queue ${q.name} was opened`); | ||
@@ -39,6 +39,2 @@ this.set('q', q); | ||
splittedBinds.forEach(bindTo => { | ||
if (failed_q) { | ||
bindTo = `failed.${bindTo}`; | ||
} | ||
console.log(bindTo); | ||
@@ -48,7 +44,17 @@ q.bind(this.exchange, bindTo, onQueueBind(q.name, bindTo)); | ||
if (!failed_q) { | ||
q.subscribe(parseIncomingMessage); | ||
} | ||
q.subscribe(parseIncomingMessage); | ||
} | ||
onFailedQueueOpen(q) { | ||
console.log(`Queue ${q.name} was opened`); | ||
this.set('q', q); | ||
const onQueueBind = this.opts.onQueueBind; | ||
const splittedBinds = this.opts.bindTo.split(","); | ||
splittedBinds.forEach(bindTo => { | ||
bindTo = `failed.${bindTo}`; | ||
console.log(bindTo); | ||
q.bind(this.exchange, bindTo, onQueueBind(q.name, bindTo)); | ||
}); | ||
} | ||
set(key, value) { | ||
@@ -65,2 +71,3 @@ this[key] = value; | ||
const onQueueOpen = this.onQueueOpen.bind(this); | ||
const onFailedQueueOpen = this.onFailedQueueOpen.bind(this); | ||
const set = this.set.bind(this); | ||
@@ -75,4 +82,4 @@ AMQP((err, connection, exchange) => { | ||
const options = { autoDelete: false, durable: true }; | ||
connection.queue(process.env.QUEUE_NAME, options, (q) => { onQueueOpen(q, false) }); | ||
connection.queue(`${process.env.QUEUE_NAME}_failed`, options, (q) => { onQueueOpen(q, true) }); | ||
connection.queue(process.env.QUEUE_NAME, options, (q) => { onQueueOpen(q) }); | ||
connection.queue(`${process.env.QUEUE_NAME}_failed`, options, (q) => { onFailedQueueOpen(q) }); | ||
}); | ||
@@ -79,0 +86,0 @@ } |
{ | ||
"name": "@techloop/amqp-broker", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "AMQP broker for microservices communication", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5080
142