@autofleet/rabbit 2.3.4 → 2.3.5

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.js CHANGED
@@ -34,7 +34,7 @@ const defaultOptions = {
34
34
  lockTimeout: DEFAULT_LOCK_TIMEOUT,
35
35
  useConsumeWithLock: DEFAULT_USE_CONSUME_WITH_LOCK,
36
36
  };
37
- const assertExchangeFanout = (c, exchangeName) => c.assertExchange(exchangeName, 'fanout');
37
+ const assertExchangeFanout = (c, exchangeName) => __awaiter(void 0, void 0, void 0, function* () { return c.assertExchange(exchangeName, 'fanout'); });
38
38
  const connectionCreatedConst = 'connectionCreated';
39
39
  const wrapSetImmediate = (callback) => new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
40
40
  setImmediate(() => __awaiter(void 0, void 0, void 0, function* () {
@@ -178,7 +178,7 @@ class RabbitMq {
178
178
  try {
179
179
  const connection = yield this.getConnection();
180
180
  if (this.channel === null) {
181
- this.channel = connection.createChannel({});
181
+ this.channel = yield connection.createChannel({});
182
182
  }
183
183
  resolve(this.channel);
184
184
  }
@@ -210,6 +210,7 @@ class RabbitMq {
210
210
  bindQueue(queue, exchange) {
211
211
  return __awaiter(this, void 0, void 0, function* () {
212
212
  const channel = yield this.assertChannel();
213
+ yield channel.addSetup((setupChannel) => setupChannel.bindQueue(queue, exchange, ''));
213
214
  // @ts-ignore
214
215
  return channel.bindQueue(queue, exchange, '');
215
216
  });
@@ -221,6 +222,7 @@ class RabbitMq {
221
222
  if (this.queues[queueName]) {
222
223
  return this.queues[queueName];
223
224
  }
225
+ yield channel.addSetup((setupChannel) => setupChannel.assertQueue(queueName, options));
224
226
  const queue = yield channel.assertQueue(queueName, options);
225
227
  this.queues[queueName] = queueName;
226
228
  return queue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -65,7 +65,7 @@ const defaultOptions = {
65
65
  useConsumeWithLock: DEFAULT_USE_CONSUME_WITH_LOCK,
66
66
  };
67
67
 
68
- const assertExchangeFanout = (c: any, exchangeName: string) => c.assertExchange(exchangeName, 'fanout');
68
+ const assertExchangeFanout = async (c: any, exchangeName: string) => c.assertExchange(exchangeName, 'fanout');
69
69
 
70
70
  const connectionCreatedConst = 'connectionCreated';
71
71
 
@@ -267,7 +267,7 @@ class RabbitMq implements IAfRabbitMq {
267
267
  try {
268
268
  const connection: AmqpConnectionManager = await this.getConnection();
269
269
  if (this.channel === null) {
270
- this.channel = connection.createChannel({});
270
+ this.channel = await connection.createChannel({});
271
271
  }
272
272
  resolve(this.channel);
273
273
  } catch (e) {
@@ -295,6 +295,7 @@ class RabbitMq implements IAfRabbitMq {
295
295
 
296
296
  async bindQueue(queue: string, exchange: string) {
297
297
  const channel: ChannelWrapper = await this.assertChannel();
298
+ await channel.addSetup((setupChannel: ConfirmChannel) => setupChannel.bindQueue(queue, exchange, ''));
298
299
  // @ts-ignore
299
300
  return channel.bindQueue(queue, exchange, '');
300
301
  }
@@ -305,6 +306,7 @@ class RabbitMq implements IAfRabbitMq {
305
306
  if (this.queues[queueName]) {
306
307
  return this.queues[queueName];
307
308
  }
309
+ await channel.addSetup((setupChannel: ConfirmChannel) => setupChannel.assertQueue(queueName, options));
308
310
  const queue = await channel.assertQueue(queueName, options);
309
311
  this.queues[queueName] = queueName;
310
312
  return queue;