@autofleet/rabbit 2.1.13 → 2.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/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(queue: string, options?: Options.AssertQueue): Promise<any>;
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
@@ -118,6 +118,8 @@ class RabbitMq {
118
118
  this.connection = connection;
119
119
  this.connection.on('disconnect', ({ err }) => {
120
120
  var _a;
121
+ this.exchanges = {};
122
+ this.queues = {};
121
123
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.reconnect) {
122
124
  console.error(`${this.RESCONNECT_MSG}${err && ` - ${err}`}`);
123
125
  this.connection = null;
@@ -183,14 +185,16 @@ class RabbitMq {
183
185
  return channel.bindQueue(queue, exchange, '');
184
186
  });
185
187
  }
186
- assertQueue(queue, options) {
188
+ assertQueue(queueName, options) {
187
189
  return __awaiter(this, void 0, void 0, function* () {
188
- RabbitMq.validateName('queue', queue);
190
+ RabbitMq.validateName('queue', queueName);
189
191
  const channel = yield this.assertChannel();
190
- if (this.queues[queue]) {
191
- return this.queues[queue];
192
+ if (this.queues[queueName]) {
193
+ return this.queues[queueName];
192
194
  }
193
- return channel.assertQueue(queue, options);
195
+ const queue = yield channel.assertQueue(queueName, options);
196
+ this.queues[queueName] = queueName;
197
+ return queue;
194
198
  });
195
199
  }
196
200
  consume(queue, callback, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "2.1.13",
3
+ "version": "2.1.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -178,6 +178,8 @@ class RabbitMq implements IAfRabbitMq {
178
178
  this.connection = connection;
179
179
  this.connection.on('disconnect',
180
180
  ({ err }) => {
181
+ this.exchanges = {};
182
+ this.queues = {};
181
183
  if (this.options?.reconnect) {
182
184
  console.error(`${this.RESCONNECT_MSG}${err && ` - ${err}`}`);
183
185
  this.connection = null;
@@ -237,13 +239,15 @@ class RabbitMq implements IAfRabbitMq {
237
239
  return channel.bindQueue(queue, exchange, '');
238
240
  }
239
241
 
240
- async assertQueue(queue: string, options?: Options.AssertQueue) {
241
- RabbitMq.validateName('queue', queue);
242
+ async assertQueue(queueName: string, options?: Options.AssertQueue) {
243
+ RabbitMq.validateName('queue', queueName);
242
244
  const channel: ChannelWrapper = await this.assertChannel();
243
- if (this.queues[queue]) {
244
- return this.queues[queue];
245
+ if (this.queues[queueName]) {
246
+ return this.queues[queueName];
245
247
  }
246
- return channel.assertQueue(queue, options);
248
+ const queue = await channel.assertQueue(queueName, options);
249
+ this.queues[queueName] = queueName;
250
+ return queue;
247
251
  }
248
252
 
249
253
  async consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {