@quatrain/queue-amqp 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,21 +54,21 @@ class AmqpQueueAdapter extends queue_1.AbstractQueueAdapter {
54
54
  }
55
55
  const concurrency = (params === null || params === void 0 ? void 0 : params.concurrency) || 0;
56
56
  queue_1.Queue.info(`Starting to listen to topic ${topic} with max concurrency set to ${concurrency}`);
57
- let concurrents = 1;
57
+ let concurrents = 0;
58
58
  yield this._connect();
59
59
  const channel = yield ((_a = this._client) === null || _a === void 0 ? void 0 : _a.createChannel());
60
60
  yield (channel === null || channel === void 0 ? void 0 : channel.assertQueue(topic));
61
61
  return channel === null || channel === void 0 ? void 0 : channel.consume(topic, (message) => __awaiter(this, void 0, void 0, function* () {
62
- // execute workflow
63
- if (concurrency > 0) {
64
- queue_1.Queue.info(`Concurrent job #${concurrents + 1} of ${concurrency} triggered`);
65
- }
66
- yield messageHandler(message.content.toString(), params);
67
- channel === null || channel === void 0 ? void 0 : channel.ack(message);
68
62
  concurrents++;
69
- if (concurrency > 0 && concurrents > concurrency) {
70
- queue_1.Queue.info(`Reached max concurrencu of ${concurrency}, exiting gracefully`);
63
+ queue_1.Queue.info(`Concurrent job #${concurrents} of ${concurrency > 0 ? concurrency : 'unlimited'} triggered`);
64
+ channel === null || channel === void 0 ? void 0 : channel.ack(message);
65
+ if (concurrency > 0 && concurrents >= concurrency) {
66
+ queue_1.Queue.info(`Reached max concurrency of ${concurrency}, disconnecting from queue`);
71
67
  yield this._disconnect();
68
+ }
69
+ yield messageHandler(message.content.toString(), params);
70
+ if (concurrency > 0 && concurrents >= concurrency) {
71
+ queue_1.Queue.info(`Reached max concurrency of ${concurrency}, exiting gracefully`);
72
72
  process.exit();
73
73
  }
74
74
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/queue-amqp",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "Queue adapter for AMQP compatible queue",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",