@quatrain/queue-amqp 1.1.14 → 1.1.15
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.
- package/lib/AmqpQueueAdapter.js +7 -6
- package/package.json +1 -1
package/lib/AmqpQueueAdapter.js
CHANGED
|
@@ -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 {
|
|
19
|
-
this._client = new amqp_client_1.AMQPClient(`amqp://${
|
|
18
|
+
const { host = 'localhost', user, password, port = 5672 } = params.config;
|
|
19
|
+
this._client = new amqp_client_1.AMQPClient(`amqp://${host}:${port}`);
|
|
20
20
|
}
|
|
21
21
|
send(data, topic) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const conn = yield this._client.connect();
|
|
24
24
|
const ch = yield conn.channel();
|
|
25
|
-
const q = yield ch.queue();
|
|
25
|
+
const q = yield ch.queue(topic);
|
|
26
26
|
const dataBuffer = Buffer.from(JSON.stringify(data));
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
queue_1.Queue.info(`[AMQP] Sending message to ${topic}`);
|
|
28
|
+
const res = yield q.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) {
|