@autofleet/rabbit 3.4.0-beta.7 → 3.4.0-beta.8

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
@@ -677,6 +677,26 @@ class RabbitMq {
677
677
  }
678
678
  // TODO: [QUORUM-PHASE-2] After changing the publish from old to new change from the old to the new implementation
679
679
  async isConnected() {
680
+ debug('rabbit: start old is connected');
681
+ const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
682
+ const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
683
+ const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
684
+ if (!oldIsConnected) {
685
+ logger_1.default.error('rabbit: isConnected - false');
686
+ return false;
687
+ }
688
+ const oldChannel = await this.assertChannelOld({ connection: this.oldPublishConnection });
689
+ try {
690
+ await Promise.all([
691
+ oldChannel.waitForConnect(),
692
+ ...this.oldConsumers.map((c) => oldChannel.checkQueue(c.queue)),
693
+ ]);
694
+ }
695
+ catch (e) {
696
+ logger_1.default.error('rabbit: isConnected - false');
697
+ return false;
698
+ }
699
+ logger_1.default.debug('rabbit: old isConnected - true');
680
700
  debug('rabbit: start is connected');
681
701
  const consumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
682
702
  const publishConnection = await this.getConnectionOld(this.oldPublishConnection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.4.0-beta.7",
3
+ "version": "3.4.0-beta.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -928,6 +928,26 @@ class RabbitMq implements IAfRabbitMq {
928
928
 
929
929
  // TODO: [QUORUM-PHASE-2] After changing the publish from old to new change from the old to the new implementation
930
930
  async isConnected() : Promise<boolean> {
931
+ debug('rabbit: start old is connected');
932
+ const oldConsumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
933
+ const oldPublishConnection = await this.getConnectionOld(this.oldPublishConnection);
934
+ const oldIsConnected = oldConsumeConnection.isConnected() && oldPublishConnection.isConnected();
935
+ if (!oldIsConnected) {
936
+ logger.error('rabbit: isConnected - false');
937
+ return false;
938
+ }
939
+ const oldChannel: any = await this.assertChannelOld({ connection: this.oldPublishConnection });
940
+ try {
941
+ await Promise.all([
942
+ oldChannel.waitForConnect(),
943
+ ...this.oldConsumers.map((c: AfConsumer) => oldChannel.checkQueue(c.queue)),
944
+ ]);
945
+ } catch (e) {
946
+ logger.error('rabbit: isConnected - false');
947
+ return false;
948
+ }
949
+ logger.debug('rabbit: old isConnected - true');
950
+
931
951
  debug('rabbit: start is connected');
932
952
  const consumeConnection = await this.getConnectionOld(this.oldConsumeConnection);
933
953
  const publishConnection = await this.getConnectionOld(this.oldPublishConnection);