@autofleet/rabbit 3.4.0-beta.7 → 3.4.0-beta.9
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 +24 -4
- package/package.json +1 -1
- package/src/index.ts +24 -4
package/dist/index.js
CHANGED
|
@@ -209,15 +209,15 @@ class RabbitMq {
|
|
|
209
209
|
this.oldPublishConnection = {
|
|
210
210
|
connection: null,
|
|
211
211
|
creatingConnection: false,
|
|
212
|
-
connectionCreatedEventName: '
|
|
213
|
-
connectionFailedEventName: '
|
|
212
|
+
connectionCreatedEventName: 'oldPublishConnectionCreated',
|
|
213
|
+
connectionFailedEventName: 'oldPublishConnectionFailed',
|
|
214
214
|
blockReconnect: false,
|
|
215
215
|
};
|
|
216
216
|
this.oldConsumeConnection = {
|
|
217
217
|
connection: null,
|
|
218
218
|
creatingConnection: false,
|
|
219
|
-
connectionCreatedEventName: '
|
|
220
|
-
connectionFailedEventName: '
|
|
219
|
+
connectionCreatedEventName: 'oldConsumeConnectionCreated',
|
|
220
|
+
connectionFailedEventName: 'oldConsumeConnectionFailed',
|
|
221
221
|
blockReconnect: false,
|
|
222
222
|
};
|
|
223
223
|
this.oldCreatingConnection = false;
|
|
@@ -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
package/src/index.ts
CHANGED
|
@@ -258,15 +258,15 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
258
258
|
this.oldPublishConnection = {
|
|
259
259
|
connection: null,
|
|
260
260
|
creatingConnection: false,
|
|
261
|
-
connectionCreatedEventName: '
|
|
262
|
-
connectionFailedEventName: '
|
|
261
|
+
connectionCreatedEventName: 'oldPublishConnectionCreated',
|
|
262
|
+
connectionFailedEventName: 'oldPublishConnectionFailed',
|
|
263
263
|
blockReconnect: false,
|
|
264
264
|
};
|
|
265
265
|
this.oldConsumeConnection = {
|
|
266
266
|
connection: null,
|
|
267
267
|
creatingConnection: false,
|
|
268
|
-
connectionCreatedEventName: '
|
|
269
|
-
connectionFailedEventName: '
|
|
268
|
+
connectionCreatedEventName: 'oldConsumeConnectionCreated',
|
|
269
|
+
connectionFailedEventName: 'oldConsumeConnectionFailed',
|
|
270
270
|
blockReconnect: false,
|
|
271
271
|
};
|
|
272
272
|
this.oldCreatingConnection = false;
|
|
@@ -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);
|