@autofleet/rabbit 3.4.0-beta.12 → 3.4.0-beta.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.js CHANGED
@@ -244,6 +244,12 @@ class RabbitMq {
244
244
  return resolve();
245
245
  }
246
246
  if (connectionLocal !== null) {
247
+ if (connection === this.publishConnection) {
248
+ debug('rabbit: getConnection publish getConnection is not null', { connectionLocal });
249
+ }
250
+ else if (connection === this.consumeConnection) {
251
+ debug('rabbit: getConnection consume getConnection is not null', { connectionLocal });
252
+ }
247
253
  if (this.options?.disableReconnect || connectionLocal?.isConnected()) {
248
254
  debug('rabbit: connection - is connected');
249
255
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -350,6 +356,15 @@ class RabbitMq {
350
356
  }
351
357
  }
352
358
  async assertChannel({ force = false, connection }) {
359
+ if (connection === this.publishConnection) {
360
+ debug('rabbit: assertChannel publish', { force, promiseSetup: this.oldPublishChannelSetupPromise });
361
+ }
362
+ else if (connection === this.consumeConnection) {
363
+ debug('rabbit: assertChannel consume', { force, promiseSetup: this.oldPublishChannelSetupPromise });
364
+ }
365
+ else {
366
+ debug('rabbit: assertChannel with undefined connection', { force, promiseSetup: this.oldPublishChannelSetupPromise, connection });
367
+ }
353
368
  if (!this.publishChannelSetupPromise) {
354
369
  this.publishChannelSetupPromise = new Promise(async (resolve, reject) => {
355
370
  if (this.publishChannel && !force) {
@@ -857,7 +872,12 @@ class RabbitMq {
857
872
  if (!localConnection) {
858
873
  throw new Error(`rabbit: couldnt get connection for new channel ${name}`);
859
874
  }
860
- debug('rabbit: getNewChannelOld', { localConnection });
875
+ if (connection === this.oldPublishConnection) {
876
+ debug('rabbit: getNewChannelOld publish', { localConnection });
877
+ }
878
+ else if (connection === this.oldConsumeConnection) {
879
+ debug('rabbit: getNewChannelOld consume', { localConnection });
880
+ }
861
881
  const channel = localConnection?.createChannel({ ...options });
862
882
  (0, events_1.once)(channel, 'close').then((args) => {
863
883
  logger_1.default.error(`rabbit: channel ${name} closed`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.4.0-beta.12",
3
+ "version": "3.4.0-beta.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -415,6 +415,7 @@ class RabbitMq implements IAfRabbitMq {
415
415
  connectionFailedEventName,
416
416
  blockReconnect,
417
417
  } = connection;
418
+
418
419
  if (connection === this.publishConnection) {
419
420
  debug('rabbit: getConnection publish', { connectionLocal, creatingConnection, blockReconnect });
420
421
  } else if (connection === this.consumeConnection) {
@@ -427,6 +428,11 @@ class RabbitMq implements IAfRabbitMq {
427
428
  return resolve();
428
429
  }
429
430
  if (connectionLocal !== null) {
431
+ if (connection === this.publishConnection) {
432
+ debug('rabbit: getConnection publish getConnection is not null', { connectionLocal });
433
+ } else if (connection === this.consumeConnection) {
434
+ debug('rabbit: getConnection consume getConnection is not null', { connectionLocal });
435
+ }
430
436
  if (this.options?.disableReconnect || connectionLocal?.isConnected()) {
431
437
  debug('rabbit: connection - is connected');
432
438
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -539,6 +545,13 @@ class RabbitMq implements IAfRabbitMq {
539
545
  }
540
546
 
541
547
  async assertChannel({ force = false, connection }: assertChannelOpts): Promise<ChannelWrapper> {
548
+ if (connection === this.publishConnection) {
549
+ debug('rabbit: assertChannel publish', { force, promiseSetup: this.oldPublishChannelSetupPromise });
550
+ } else if (connection === this.consumeConnection) {
551
+ debug('rabbit: assertChannel consume', { force, promiseSetup: this.oldPublishChannelSetupPromise });
552
+ } else {
553
+ debug('rabbit: assertChannel with undefined connection', { force, promiseSetup: this.oldPublishChannelSetupPromise, connection });
554
+ }
542
555
  if (!this.publishChannelSetupPromise) {
543
556
  this.publishChannelSetupPromise = new Promise<ChannelWrapper>(async (resolve, reject) => {
544
557
  if (this.publishChannel && !force) {
@@ -1124,8 +1137,11 @@ class RabbitMq implements IAfRabbitMq {
1124
1137
  if (!localConnection) {
1125
1138
  throw new Error(`rabbit: couldnt get connection for new channel ${name}`);
1126
1139
  }
1127
-
1128
- debug('rabbit: getNewChannelOld', { localConnection });
1140
+ if (connection === this.oldPublishConnection) {
1141
+ debug('rabbit: getNewChannelOld publish', { localConnection });
1142
+ } else if (connection === this.oldConsumeConnection) {
1143
+ debug('rabbit: getNewChannelOld consume', { localConnection });
1144
+ }
1129
1145
  const channel = localConnection?.createChannel({ ...options });
1130
1146
  once(channel, 'close').then((args) => {
1131
1147
  logger.error(`rabbit: channel ${name} closed`);