@autofleet/rabbit 3.4.0-beta.3 → 3.4.0-beta.4
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 +10 -0
- package/package.json +1 -1
- package/src/index.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -717,6 +717,7 @@ class RabbitMq {
|
|
|
717
717
|
}
|
|
718
718
|
async consumeFromRabbitOld(queue, callback, options) {
|
|
719
719
|
const optionsWithDefaults = { ...consts_1.DEFAULT_OPTIONS, ...options };
|
|
720
|
+
debug('rabbit: consumeFromRabbitOld', { queue });
|
|
720
721
|
RabbitMq.validateName('queue', queue);
|
|
721
722
|
this.saveConsumerOld(queue, callback, options);
|
|
722
723
|
const uniqueId = (0, node_crypto_1.randomUUID)();
|
|
@@ -808,6 +809,12 @@ class RabbitMq {
|
|
|
808
809
|
// TODO: [QUORUM-PHASE-3] Delete all the function under this line (getNewChannelOld, getConnectionOld, assertQueueOld, setupQueueOld, saveConsumerOld)
|
|
809
810
|
async getNewChannelOld({ name = (0, utils_1.rand)().toString(), onClose = null, options = {}, connection, }) {
|
|
810
811
|
let localConnection;
|
|
812
|
+
if (connection === this.oldPublishConnection) {
|
|
813
|
+
debug('rabbit: getConnectionOld publish', { connection });
|
|
814
|
+
}
|
|
815
|
+
else if (connection === this.oldConsumeConnection) {
|
|
816
|
+
debug('rabbit: getConnectionOld consume', { connection });
|
|
817
|
+
}
|
|
811
818
|
try {
|
|
812
819
|
localConnection = await this.getConnectionOld(connection);
|
|
813
820
|
}
|
|
@@ -815,6 +822,9 @@ class RabbitMq {
|
|
|
815
822
|
logger_1.default.error(`rabbit: error on get connection for new channel ${name} `, { e });
|
|
816
823
|
throw e;
|
|
817
824
|
}
|
|
825
|
+
if (!localConnection) {
|
|
826
|
+
throw new Error(`rabbit: couldnt get connection for new channel ${name}`);
|
|
827
|
+
}
|
|
818
828
|
debug('rabbit: getNewChannelOld', { localConnection });
|
|
819
829
|
const channel = localConnection.createChannel({ ...options });
|
|
820
830
|
(0, events_1.once)(channel, 'close').then((args) => {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -970,6 +970,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
970
970
|
|
|
971
971
|
private async consumeFromRabbitOld(queue: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any> {
|
|
972
972
|
const optionsWithDefaults = { ...DEFAULT_OPTIONS, ...options };
|
|
973
|
+
debug('rabbit: consumeFromRabbitOld', { queue });
|
|
973
974
|
RabbitMq.validateName('queue', queue);
|
|
974
975
|
this.saveConsumerOld(queue, callback, options);
|
|
975
976
|
const uniqueId = randomUUID();
|
|
@@ -1077,12 +1078,22 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
1077
1078
|
name = rand().toString(), onClose = null, options = {}, connection,
|
|
1078
1079
|
}: newChannelOpts) {
|
|
1079
1080
|
let localConnection!: AmqpConnectionManager;
|
|
1081
|
+
if (connection === this.oldPublishConnection) {
|
|
1082
|
+
debug('rabbit: getConnectionOld publish', { connection });
|
|
1083
|
+
} else if (connection === this.oldConsumeConnection) {
|
|
1084
|
+
debug('rabbit: getConnectionOld consume', { connection });
|
|
1085
|
+
}
|
|
1080
1086
|
try {
|
|
1081
1087
|
localConnection = await this.getConnectionOld(connection);
|
|
1082
1088
|
} catch (e) {
|
|
1083
1089
|
logger.error(`rabbit: error on get connection for new channel ${name} `, { e });
|
|
1084
1090
|
throw e;
|
|
1085
1091
|
}
|
|
1092
|
+
|
|
1093
|
+
if (!localConnection) {
|
|
1094
|
+
throw new Error(`rabbit: couldnt get connection for new channel ${name}`);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1086
1097
|
debug('rabbit: getNewChannelOld', { localConnection });
|
|
1087
1098
|
const channel = localConnection.createChannel({ ...options });
|
|
1088
1099
|
once(channel, 'close').then((args) => {
|