@autofleet/rabbit 2.1.13 → 2.1.14
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/dist/index.d.ts +1 -1
- package/dist/index.js +7 -5
- package/package.json +1 -1
- package/src/index.ts +7 -5
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
56
56
|
assertExchange(exchangeName: string, options?: any): Promise<any>;
|
|
57
57
|
getQueueLength(queue: string): Promise<import("amqplib").Replies.AssertQueue>;
|
|
58
58
|
bindQueue(queue: string, exchange: string): Promise<void>;
|
|
59
|
-
assertQueue(
|
|
59
|
+
assertQueue(queueName: string, options?: Options.AssertQueue): Promise<any>;
|
|
60
60
|
consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
|
|
61
61
|
consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
|
|
62
62
|
publish(exchange: string, content: any, customHeaders?: any): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -183,14 +183,16 @@ class RabbitMq {
|
|
|
183
183
|
return channel.bindQueue(queue, exchange, '');
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
assertQueue(
|
|
186
|
+
assertQueue(queueName, options) {
|
|
187
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
RabbitMq.validateName('queue',
|
|
188
|
+
RabbitMq.validateName('queue', queueName);
|
|
189
189
|
const channel = yield this.assertChannel();
|
|
190
|
-
if (this.queues[
|
|
191
|
-
return this.queues[
|
|
190
|
+
if (this.queues[queueName]) {
|
|
191
|
+
return this.queues[queueName];
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
const queue = yield channel.assertQueue(queueName, options);
|
|
194
|
+
this.queues[queueName] = queueName;
|
|
195
|
+
return queue;
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
consume(queue, callback, options) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -237,13 +237,15 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
237
237
|
return channel.bindQueue(queue, exchange, '');
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
async assertQueue(
|
|
241
|
-
RabbitMq.validateName('queue',
|
|
240
|
+
async assertQueue(queueName: string, options?: Options.AssertQueue) {
|
|
241
|
+
RabbitMq.validateName('queue', queueName);
|
|
242
242
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
243
|
-
if (this.queues[
|
|
244
|
-
return this.queues[
|
|
243
|
+
if (this.queues[queueName]) {
|
|
244
|
+
return this.queues[queueName];
|
|
245
245
|
}
|
|
246
|
-
|
|
246
|
+
const queue = await channel.assertQueue(queueName, options);
|
|
247
|
+
this.queues[queueName] = queueName;
|
|
248
|
+
return queue;
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
async consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
|