@ecom-micro/common 2.0.47 → 2.0.50
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.
|
@@ -22,6 +22,7 @@ class BaseListener {
|
|
|
22
22
|
const consumeQueue = yield this.channel.assertQueue(this.routingKey, {
|
|
23
23
|
durable: true,
|
|
24
24
|
});
|
|
25
|
+
this.channel.prefetch(1);
|
|
25
26
|
yield this.channel.bindQueue(consumeQueue.queue, this.exchangeName, this.routingKey);
|
|
26
27
|
this.channel.consume(consumeQueue.queue, (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
console.log(`Message received: ${this.exchangeName} / ${this.routingKey}`);
|
|
@@ -29,7 +30,9 @@ class BaseListener {
|
|
|
29
30
|
const parsedData = JSON.parse(msg.content.toString());
|
|
30
31
|
this.onMessage(parsedData, this.channel, msg);
|
|
31
32
|
}
|
|
32
|
-
})
|
|
33
|
+
}), {
|
|
34
|
+
noAck: false,
|
|
35
|
+
});
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -16,8 +16,12 @@ class BasePublisher {
|
|
|
16
16
|
}
|
|
17
17
|
publish(data) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
yield this.channel.assertExchange(this.exchangeName, 'direct'
|
|
20
|
-
|
|
19
|
+
yield this.channel.assertExchange(this.exchangeName, 'direct', {
|
|
20
|
+
durable: true,
|
|
21
|
+
});
|
|
22
|
+
this.channel.publish(this.exchangeName, this.routingKey, Buffer.from(JSON.stringify(data)), {
|
|
23
|
+
persistent: true,
|
|
24
|
+
});
|
|
21
25
|
console.log(`Message published Exchange:${this.exchangeName} / RoutingKey: ${this.routingKey}`);
|
|
22
26
|
});
|
|
23
27
|
}
|