@techloop/amqp-broker
Advanced tools
Comparing version 1.3.6 to 1.3.7
@@ -15,3 +15,3 @@ if (!process.env.EXCHANGE_NAME) { | ||
`Queue ${name}.${ | ||
bindTo | ||
bindTo | ||
} binded successfully` | ||
@@ -29,2 +29,3 @@ ); | ||
this.connection = null; | ||
this.exchange = null; | ||
} | ||
@@ -34,3 +35,3 @@ | ||
console.log(`Queue ${q.name} was opened`); | ||
this.set("q", q); | ||
this.set('q', q); | ||
const onQueueBind = this.opts.onQueueBind; | ||
@@ -67,4 +68,4 @@ const parseIncomingMessage = this.parseIncomingMessage.bind(this); | ||
} | ||
set("connection", connection); | ||
set("exchange", exchange); | ||
set('connection', connection); | ||
set('exchange', exchange); | ||
const options = { autoDelete: false, durable: true }; | ||
@@ -105,6 +106,19 @@ connection.queue(process.env.QUEUE_NAME, options, (q) => { onQueueOpen(false, q) }); | ||
console.log('Found matching Task: ', Task) | ||
Task.callback({ | ||
msg: data, | ||
key: deliveryInfo.routingKey | ||
}); | ||
try { | ||
Task.callback({ | ||
msg: data, | ||
key: deliveryInfo.routingKey | ||
}); | ||
} catch (error) { | ||
console.error(`Error: failed to run callback for task key=${deliveryInfo.routingKey}`, error); | ||
if (Task.handleFailedMessages) { | ||
const failureRoutingKey = `failed.${Task.key}`; | ||
this.exchange.publish(failureRoutingKey, data, {}, (err) => { | ||
console.error('Can not publish message', err) | ||
}); | ||
} | ||
} | ||
} | ||
@@ -111,0 +125,0 @@ } |
{ | ||
"name": "@techloop/amqp-broker", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"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
4850
140