@autofleet/rabbit 3.4.0-beta.14 → 3.4.0-beta.16

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.
Files changed (3) hide show
  1. package/dist/index.js +44 -42
  2. package/package.json +1 -1
  3. package/src/index.ts +43 -43
package/dist/index.js CHANGED
@@ -319,7 +319,7 @@ class RabbitMq {
319
319
  newConnection.once('connect', async () => {
320
320
  debug('rabbit: connection established');
321
321
  connection.creatingConnection = false;
322
- this.em.emit(connectionCreatedEventName, connection);
322
+ this.em.emit(connectionCreatedEventName, newConnection);
323
323
  isResolved = true;
324
324
  resolve(newConnection);
325
325
  });
@@ -702,47 +702,49 @@ class RabbitMq {
702
702
  }
703
703
  // TODO: [QUORUM-PHASE-2] After changing the publish from old to new change from the old to the new implementation
704
704
  async isConnected() {
705
- debug('rabbit: start old is connected', { connection: this.oldPublishConnection.connectionCreatedEventName });
705
+ // TODO: OLD IMPLEMENTATION
706
+ debug('rabbit: start old is connected');
707
+ const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
708
+ const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
709
+ const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
710
+ if (!oldIsConnected) {
711
+ logger_1.default.error('rabbit: isConnected - false');
712
+ return false;
713
+ }
714
+ const oldChannel = await this.assertChannelOld({ connection: this.oldPublishConnection });
715
+ try {
716
+ await Promise.all([
717
+ oldChannel.waitForConnect(),
718
+ ...this.oldConsumers.map((c) => oldChannel.checkQueue(c.queue)),
719
+ ]);
720
+ }
721
+ catch (e) {
722
+ logger_1.default.error('rabbit: isConnected - false');
723
+ return false;
724
+ }
725
+ logger_1.default.debug('rabbit: old isConnected - true');
726
+ // TODO: NEW IMPLEMENTATION
727
+ debug('rabbit: start is connected');
728
+ const consumeConnection = await this.getConnection(this.consumeConnection);
729
+ const publishConnection = await this.getConnection(this.publishConnection);
730
+ const isConnected = consumeConnection.isConnected() && publishConnection.isConnected();
731
+ if (!isConnected) {
732
+ logger_1.default.error('rabbit: isConnected - false');
733
+ return false;
734
+ }
735
+ const channel = await this.assertChannel({ connection: this.publishConnection });
736
+ try {
737
+ await Promise.all([
738
+ channel.waitForConnect(),
739
+ ...this.consumers.map((c) => channel.checkQueue(c.queue)),
740
+ ]);
741
+ }
742
+ catch (e) {
743
+ logger_1.default.error('rabbit: isConnected - false');
744
+ return false;
745
+ }
746
+ logger_1.default.debug('rabbit: isConnected - true');
706
747
  return true;
707
- // debug('rabbit: start old is connected');
708
- // const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
709
- // const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
710
- // const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
711
- // if (!oldIsConnected) {
712
- // logger.error('rabbit: isConnected - false');
713
- // return false;
714
- // }
715
- // const oldChannel: any = await this.assertChannelOld({ connection: this.oldPublishConnection });
716
- // try {
717
- // await Promise.all([
718
- // oldChannel.waitForConnect(),
719
- // ...this.oldConsumers.map((c: AfConsumer) => oldChannel.checkQueue(c.queue)),
720
- // ]);
721
- // } catch (e) {
722
- // logger.error('rabbit: isConnected - false');
723
- // return false;
724
- // }
725
- // logger.debug('rabbit: old isConnected - true');
726
- // debug('rabbit: start is connected');
727
- // const consumeConnection = await this.getConnection(this.oldConsumeConnection);
728
- // const publishConnection = await this.getConnection(this.oldPublishConnection);
729
- // const isConnected = consumeConnection.isConnected() && publishConnection.isConnected();
730
- // if (!isConnected) {
731
- // logger.error('rabbit: isConnected - false');
732
- // return false;
733
- // }
734
- // const channel: any = await this.assertChannel({ connection: this.oldPublishConnection });
735
- // try {
736
- // await Promise.all([
737
- // channel.waitForConnect(),
738
- // ...this.oldConsumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
739
- // ]);
740
- // } catch (e) {
741
- // logger.error('rabbit: isConnected - false');
742
- // return false;
743
- // }
744
- // logger.debug('rabbit: isConnected - true');
745
- // return true;
746
748
  }
747
749
  async gracefulShutdown(signal) {
748
750
  // TODO: [QUORUM-PHASE-2] After changing the publish from old to new change from the old to the new implementation
@@ -977,7 +979,7 @@ class RabbitMq {
977
979
  newConnection.once('connect', async () => {
978
980
  debug('rabbit: connection established');
979
981
  connection.creatingConnection = false;
980
- this.oldEm.emit(connectionCreatedEventName, connection);
982
+ this.oldEm.emit(connectionCreatedEventName, newConnection);
981
983
  isResolved = true;
982
984
  resolve(newConnection);
983
985
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.4.0-beta.14",
3
+ "version": "3.4.0-beta.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -507,7 +507,7 @@ class RabbitMq implements IAfRabbitMq {
507
507
  newConnection.once('connect', async () => {
508
508
  debug('rabbit: connection established');
509
509
  connection.creatingConnection = false;
510
- this.em.emit(connectionCreatedEventName, connection);
510
+ this.em.emit(connectionCreatedEventName, newConnection);
511
511
  isResolved = true;
512
512
  resolve(newConnection);
513
513
  });
@@ -950,48 +950,48 @@ class RabbitMq implements IAfRabbitMq {
950
950
 
951
951
  // TODO: [QUORUM-PHASE-2] After changing the publish from old to new change from the old to the new implementation
952
952
  async isConnected() : Promise<boolean> {
953
- debug('rabbit: start old is connected', { connection: this.oldPublishConnection.connectionCreatedEventName });
953
+ // TODO: OLD IMPLEMENTATION
954
+ debug('rabbit: start old is connected');
955
+ const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
956
+ const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
957
+ const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
958
+ if (!oldIsConnected) {
959
+ logger.error('rabbit: isConnected - false');
960
+ return false;
961
+ }
962
+ const oldChannel: any = await this.assertChannelOld({ connection: this.oldPublishConnection });
963
+ try {
964
+ await Promise.all([
965
+ oldChannel.waitForConnect(),
966
+ ...this.oldConsumers.map((c: AfConsumer) => oldChannel.checkQueue(c.queue)),
967
+ ]);
968
+ } catch (e) {
969
+ logger.error('rabbit: isConnected - false');
970
+ return false;
971
+ }
972
+ logger.debug('rabbit: old isConnected - true');
973
+
974
+ // TODO: NEW IMPLEMENTATION
975
+ debug('rabbit: start is connected');
976
+ const consumeConnection = await this.getConnection(this.consumeConnection);
977
+ const publishConnection = await this.getConnection(this.publishConnection);
978
+ const isConnected = consumeConnection.isConnected() && publishConnection.isConnected();
979
+ if (!isConnected) {
980
+ logger.error('rabbit: isConnected - false');
981
+ return false;
982
+ }
983
+ const channel: any = await this.assertChannel({ connection: this.publishConnection });
984
+ try {
985
+ await Promise.all([
986
+ channel.waitForConnect(),
987
+ ...this.consumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
988
+ ]);
989
+ } catch (e) {
990
+ logger.error('rabbit: isConnected - false');
991
+ return false;
992
+ }
993
+ logger.debug('rabbit: isConnected - true');
954
994
  return true;
955
- // debug('rabbit: start old is connected');
956
- // const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
957
- // const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
958
- // const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
959
- // if (!oldIsConnected) {
960
- // logger.error('rabbit: isConnected - false');
961
- // return false;
962
- // }
963
- // const oldChannel: any = await this.assertChannelOld({ connection: this.oldPublishConnection });
964
- // try {
965
- // await Promise.all([
966
- // oldChannel.waitForConnect(),
967
- // ...this.oldConsumers.map((c: AfConsumer) => oldChannel.checkQueue(c.queue)),
968
- // ]);
969
- // } catch (e) {
970
- // logger.error('rabbit: isConnected - false');
971
- // return false;
972
- // }
973
- // logger.debug('rabbit: old isConnected - true');
974
-
975
- // debug('rabbit: start is connected');
976
- // const consumeConnection = await this.getConnection(this.oldConsumeConnection);
977
- // const publishConnection = await this.getConnection(this.oldPublishConnection);
978
- // const isConnected = consumeConnection.isConnected() && publishConnection.isConnected();
979
- // if (!isConnected) {
980
- // logger.error('rabbit: isConnected - false');
981
- // return false;
982
- // }
983
- // const channel: any = await this.assertChannel({ connection: this.oldPublishConnection });
984
- // try {
985
- // await Promise.all([
986
- // channel.waitForConnect(),
987
- // ...this.oldConsumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
988
- // ]);
989
- // } catch (e) {
990
- // logger.error('rabbit: isConnected - false');
991
- // return false;
992
- // }
993
- // logger.debug('rabbit: isConnected - true');
994
- // return true;
995
995
  }
996
996
 
997
997
  async gracefulShutdown(signal: string) : Promise<void> {
@@ -1253,7 +1253,7 @@ class RabbitMq implements IAfRabbitMq {
1253
1253
  newConnection.once('connect', async () => {
1254
1254
  debug('rabbit: connection established');
1255
1255
  connection.creatingConnection = false;
1256
- this.oldEm.emit(connectionCreatedEventName, connection);
1256
+ this.oldEm.emit(connectionCreatedEventName, newConnection);
1257
1257
  isResolved = true;
1258
1258
  resolve(newConnection);
1259
1259
  });