@quatrain/queue-amqp 1.1.14 → 1.1.16

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.
@@ -15,18 +15,19 @@ const amqp_client_1 = require("@cloudamqp/amqp-client");
15
15
  class AmqpQueueAdapter extends queue_1.AbstractQueueAdapter {
16
16
  constructor(params) {
17
17
  super(params);
18
- const { url = 'localhost', user, password, port = 5672 } = params.config;
19
- this._client = new amqp_client_1.AMQPClient(`amqp://${url}:${port}`);
18
+ const { host = 'localhost', user = 'guest', password = 'guest', port = 5672, } = params.config || {};
19
+ this._client = new amqp_client_1.AMQPClient(`amqp://${user}:${password}@${host}:${port}`);
20
20
  }
21
21
  send(data, topic) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- const conn = yield this._client.connect();
24
- const ch = yield conn.channel();
25
- const q = yield ch.queue();
23
+ const connection = yield this._client.connect();
24
+ const channel = yield connection.channel();
25
+ const queue = yield channel.queue(topic);
26
26
  const dataBuffer = Buffer.from(JSON.stringify(data));
27
- const messageId = yield q.publish(dataBuffer, { deliveryMode: 2 });
28
- queue_1.Queue.log(`[AMQP] Sending message to ${topic}`);
29
- return messageId;
27
+ queue_1.Queue.info(`[AMQP] Sending message to ${topic}`);
28
+ const res = yield queue.publish(dataBuffer, { deliveryMode: 2 });
29
+ queue_1.Queue.info(`[AMQP] Message send with id ${res.confirmId}`);
30
+ return res.confirmId;
30
31
  });
31
32
  }
32
33
  listen(topic = this._params.topic, messageHandler) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/queue-amqp",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
4
4
  "description": "Queue adapter for AMQP compatible queue",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@cloudamqp/amqp-client": "^3.1.1",
28
28
  "@quatrain/core": "^1.1.18",
29
- "@quatrain/queue": "^1.1.13"
29
+ "@quatrain/queue": "^1.1.15"
30
30
  },
31
31
  "scripts": {
32
32
  "test-ci": "jest --runInBand",