@autofleet/rabbit 3.2.26-beta.4 → 3.3.0-beta.1
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 +17 -32
- package/package.json +1 -1
- package/src/index.ts +16 -33
package/dist/index.js
CHANGED
|
@@ -554,48 +554,33 @@ class RabbitMq {
|
|
|
554
554
|
throw e;
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
// const connection = await this.getConnection();
|
|
558
|
-
// const isConnected = connection.isConnected();
|
|
559
|
-
// if (!isConnected) {
|
|
560
|
-
// logger.error('rabbit: isConnected - false');
|
|
561
|
-
// return false;
|
|
562
|
-
// }
|
|
563
|
-
// const channel: any = await this.assertChannel();
|
|
564
|
-
// try {
|
|
565
|
-
// await Promise.all([
|
|
566
|
-
// channel.waitForConnect(),
|
|
567
|
-
// ...this.consumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
|
|
568
|
-
// ]);
|
|
569
|
-
// } catch (e) {
|
|
570
|
-
// logger.error('rabbit: isConnected - false');
|
|
571
|
-
// return false;
|
|
572
|
-
// }
|
|
573
|
-
// logger.info('rabbit: isConnected - true');
|
|
574
|
-
// return true;
|
|
575
557
|
async isConnected() {
|
|
576
558
|
debug('rabbit: start is connected');
|
|
577
559
|
const isEachConnectionConnected = await Promise.all(Object.entries(this.connectionsMap).map(async ([connectionPurpose, connectionData]) => {
|
|
578
560
|
const { connection } = connectionData;
|
|
579
|
-
if (connectionPurpose === consts_1.ConnectionPurpose.Publish && connection) {
|
|
580
|
-
const channel = await this.assertChannel({ connectionPurpose: connectionPurpose });
|
|
581
|
-
try {
|
|
582
|
-
await Promise.all([
|
|
583
|
-
channel.waitForConnect(),
|
|
584
|
-
...this.consumers.map((c) => channel.checkQueue(c.queue)),
|
|
585
|
-
]);
|
|
586
|
-
}
|
|
587
|
-
catch (e) {
|
|
588
|
-
logger_1.default.error('rabbit: isConnected - false');
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
561
|
if (connection) {
|
|
593
|
-
const isConnected = connection
|
|
562
|
+
const isConnected = connection.isConnected();
|
|
594
563
|
if (!isConnected) {
|
|
595
564
|
logger_1.default.error('rabbit: isConnected - false', { connectionPurpose });
|
|
596
565
|
return false;
|
|
597
566
|
}
|
|
598
567
|
logger_1.default.info('rabbit: isConnected - true', { connectionPurpose });
|
|
568
|
+
if (connectionPurpose === consts_1.ConnectionPurpose.Publish) {
|
|
569
|
+
const channel = await this.assertChannel({ connectionPurpose: connectionPurpose });
|
|
570
|
+
try {
|
|
571
|
+
await Promise.all([
|
|
572
|
+
channel.waitForConnect(),
|
|
573
|
+
...this.consumers.map((c) => channel.checkQueue(c.queue)),
|
|
574
|
+
]);
|
|
575
|
+
}
|
|
576
|
+
catch (e) {
|
|
577
|
+
logger_1.default.error('rabbit: isConnected - false');
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
logger_1.default.info('rabbit: connection hasnt initialized yet', { connectionPurpose });
|
|
599
584
|
}
|
|
600
585
|
return true;
|
|
601
586
|
}));
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -758,50 +758,33 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
// const connection = await this.getConnection();
|
|
762
|
-
// const isConnected = connection.isConnected();
|
|
763
|
-
// if (!isConnected) {
|
|
764
|
-
// logger.error('rabbit: isConnected - false');
|
|
765
|
-
// return false;
|
|
766
|
-
// }
|
|
767
|
-
// const channel: any = await this.assertChannel();
|
|
768
|
-
// try {
|
|
769
|
-
// await Promise.all([
|
|
770
|
-
// channel.waitForConnect(),
|
|
771
|
-
// ...this.consumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
|
|
772
|
-
// ]);
|
|
773
|
-
// } catch (e) {
|
|
774
|
-
// logger.error('rabbit: isConnected - false');
|
|
775
|
-
// return false;
|
|
776
|
-
// }
|
|
777
|
-
// logger.info('rabbit: isConnected - true');
|
|
778
|
-
// return true;
|
|
779
|
-
|
|
780
761
|
async isConnected(): Promise<boolean> {
|
|
781
762
|
debug('rabbit: start is connected');
|
|
782
763
|
const isEachConnectionConnected = await Promise.all(
|
|
783
764
|
Object.entries(this.connectionsMap).map(async ([connectionPurpose, connectionData]) => {
|
|
784
765
|
const { connection } = connectionData;
|
|
785
|
-
if (connectionPurpose === ConnectionPurpose.Publish && connection) {
|
|
786
|
-
const channel: any = await this.assertChannel({ connectionPurpose: connectionPurpose as ConnectionPurpose });
|
|
787
|
-
try {
|
|
788
|
-
await Promise.all([
|
|
789
|
-
channel.waitForConnect(),
|
|
790
|
-
...this.consumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
|
|
791
|
-
]);
|
|
792
|
-
} catch (e) {
|
|
793
|
-
logger.error('rabbit: isConnected - false');
|
|
794
|
-
return false;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
766
|
if (connection) {
|
|
799
|
-
const isConnected = connection
|
|
767
|
+
const isConnected = connection.isConnected();
|
|
800
768
|
if (!isConnected) {
|
|
801
769
|
logger.error('rabbit: isConnected - false', { connectionPurpose });
|
|
802
770
|
return false;
|
|
803
771
|
}
|
|
804
772
|
logger.info('rabbit: isConnected - true', { connectionPurpose });
|
|
773
|
+
|
|
774
|
+
if (connectionPurpose === ConnectionPurpose.Publish) {
|
|
775
|
+
const channel: any = await this.assertChannel({ connectionPurpose: connectionPurpose as ConnectionPurpose });
|
|
776
|
+
try {
|
|
777
|
+
await Promise.all([
|
|
778
|
+
channel.waitForConnect(),
|
|
779
|
+
...this.consumers.map((c: AfConsumer) => channel.checkQueue(c.queue)),
|
|
780
|
+
]);
|
|
781
|
+
} catch (e) {
|
|
782
|
+
logger.error('rabbit: isConnected - false');
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
} else {
|
|
787
|
+
logger.info('rabbit: connection hasnt initialized yet', { connectionPurpose });
|
|
805
788
|
}
|
|
806
789
|
return true;
|
|
807
790
|
}),
|