@autofleet/rabbit 3.3.0-beta.10 → 3.3.0-beta.11
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 -22
- package/package.json +1 -1
- package/src/index.ts +18 -23
package/dist/index.js
CHANGED
|
@@ -136,11 +136,11 @@ class RabbitMq {
|
|
|
136
136
|
await this.unlockRedisIfNeeded(releaseLock);
|
|
137
137
|
if (channel && msg) {
|
|
138
138
|
if (!skipRetry
|
|
139
|
-
&& (!msg.properties.headers
|
|
140
|
-
|| parseInt(msg.properties.headers
|
|
139
|
+
&& (!msg.properties.headers[consts_1.RETRY_HEADER]
|
|
140
|
+
|| parseInt(msg.properties.headers[consts_1.RETRY_HEADER], 10) < options.retries)) {
|
|
141
141
|
await this.sendToQueue(queue, RabbitMq.parseMsg(msg).content, options, {
|
|
142
142
|
...msg.properties.headers,
|
|
143
|
-
[consts_1.RETRY_HEADER]: msg.properties.headers
|
|
143
|
+
[consts_1.RETRY_HEADER]: msg.properties.headers[consts_1.RETRY_HEADER]
|
|
144
144
|
? msg.properties.headers[consts_1.RETRY_HEADER] + 1
|
|
145
145
|
: 1,
|
|
146
146
|
});
|
|
@@ -149,7 +149,7 @@ class RabbitMq {
|
|
|
149
149
|
const deadQueue = `${queue}-dead`;
|
|
150
150
|
await this.sendToQueue(deadQueue, RabbitMq.parseMsg(msg).content, deadQueueOptions, {
|
|
151
151
|
...msg.properties.headers,
|
|
152
|
-
[consts_1.RETRY_HEADER]: msg.properties.headers
|
|
152
|
+
[consts_1.RETRY_HEADER]: msg.properties.headers[consts_1.RETRY_HEADER]
|
|
153
153
|
? msg.properties.headers[consts_1.RETRY_HEADER] + 1
|
|
154
154
|
: 1,
|
|
155
155
|
});
|
|
@@ -479,16 +479,16 @@ class RabbitMq {
|
|
|
479
479
|
}
|
|
480
480
|
const channel = await this.getNewChannel({});
|
|
481
481
|
return channel.addSetup(async (confirmChannel) => {
|
|
482
|
-
|
|
482
|
+
throw new Error('Dummy assertQueue error');
|
|
483
483
|
const q = await this.assertQueue(queue, optionsWithDefaults);
|
|
484
484
|
await confirmChannel.prefetch(limit, false);
|
|
485
485
|
const { consumerTag } = await confirmChannel.consume(queue, async (msg) => {
|
|
486
486
|
if (!msg) {
|
|
487
487
|
return null;
|
|
488
488
|
}
|
|
489
|
-
const traceId = msg.properties.headers
|
|
490
|
-
const userId = msg.properties.headers
|
|
491
|
-
const automationId = msg.properties.headers
|
|
489
|
+
const traceId = msg.properties.headers[consts_1.TRACING_HEADER];
|
|
490
|
+
const userId = msg.properties.headers[consts_1.USER_TRACING_HEADER];
|
|
491
|
+
const automationId = msg.properties.headers[consts_1.AUTOMATION_ID_HEADER];
|
|
492
492
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
493
493
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
494
494
|
const trace = (0, zehut_1.newTrace)(zehut_1.traceTypes.RABBIT);
|
|
@@ -583,11 +583,11 @@ class RabbitMq {
|
|
|
583
583
|
const channelOld = await this.getNewChannelOld({ name: `consume-exchange-${exchange}-queue-${queue}-old` });
|
|
584
584
|
await channelOld.addSetup(async (c) => {
|
|
585
585
|
const assertExchange = await (0, utils_1.assertExchangeFanout)(c, exchange);
|
|
586
|
-
|
|
586
|
+
await c.assertQueue(queue);
|
|
587
587
|
this.oldExchanges[exchange] = assertExchange;
|
|
588
588
|
await c.prefetch(limit, false);
|
|
589
589
|
return Promise.all([
|
|
590
|
-
|
|
590
|
+
c.bindQueue(queue, exchange, ''),
|
|
591
591
|
this.consumeOld(queue, callback, options),
|
|
592
592
|
]);
|
|
593
593
|
});
|
|
@@ -691,9 +691,9 @@ class RabbitMq {
|
|
|
691
691
|
if (!msg) {
|
|
692
692
|
return null;
|
|
693
693
|
}
|
|
694
|
-
const traceId = msg.properties.headers
|
|
695
|
-
const userId = msg.properties.headers
|
|
696
|
-
const automationId = msg.properties.headers
|
|
694
|
+
const traceId = msg.properties.headers[consts_1.TRACING_HEADER];
|
|
695
|
+
const userId = msg.properties.headers[consts_1.USER_TRACING_HEADER];
|
|
696
|
+
const automationId = msg.properties.headers[consts_1.AUTOMATION_ID_HEADER];
|
|
697
697
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
698
698
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
699
699
|
const trace = (0, zehut_1.newTrace)(zehut_1.traceTypes.RABBIT);
|
|
@@ -887,7 +887,7 @@ class RabbitMq {
|
|
|
887
887
|
return this.oldQueueSetupPromises[queueName];
|
|
888
888
|
}
|
|
889
889
|
async setupQueueOld(queueName, options) {
|
|
890
|
-
|
|
890
|
+
let queue;
|
|
891
891
|
const shouldUseQuorum = RabbitMq.shouldUseQuorum(queueName);
|
|
892
892
|
const localeOptions = {
|
|
893
893
|
...options,
|
|
@@ -901,9 +901,9 @@ class RabbitMq {
|
|
|
901
901
|
try {
|
|
902
902
|
const channel = await this.assertChannelOld();
|
|
903
903
|
debug('assertQueue->channel.addSetup', { queueName });
|
|
904
|
-
|
|
904
|
+
await channel.addSetup((setupChannel) => setupChannel.assertQueue(queueName, localeOptions));
|
|
905
905
|
debug('assertQueue->channel.assertQueue', { queueName });
|
|
906
|
-
|
|
906
|
+
queue = await channel.assertQueue(queueName, localeOptions);
|
|
907
907
|
}
|
|
908
908
|
catch (e) {
|
|
909
909
|
logger_1.default.error('rabbit: assertQueue error', { queueName, options, error: e });
|
|
@@ -914,17 +914,12 @@ class RabbitMq {
|
|
|
914
914
|
debug('retrying assertQueue->channel.addSetup', { queueName });
|
|
915
915
|
await channel.addSetup((setupChannel) => setupChannel.assertQueue(queueName, localeOptions));
|
|
916
916
|
debug('retrying assertQueue->channel.assertQueue', { queueName });
|
|
917
|
-
|
|
917
|
+
queue = await channel.assertQueue(queueName, localeOptions);
|
|
918
918
|
}
|
|
919
919
|
else {
|
|
920
920
|
throw e;
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
const queue = {
|
|
924
|
-
queue: 'bla bla queue',
|
|
925
|
-
messageCount: 0,
|
|
926
|
-
consumerCount: 2,
|
|
927
|
-
};
|
|
928
923
|
this.oldQueues[queueName] = queue;
|
|
929
924
|
return queue;
|
|
930
925
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -345,13 +345,13 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
345
345
|
if (
|
|
346
346
|
!skipRetry
|
|
347
347
|
&& (
|
|
348
|
-
!msg.properties.headers
|
|
349
|
-
|| parseInt(msg.properties.headers
|
|
348
|
+
!msg.properties.headers[RETRY_HEADER]
|
|
349
|
+
|| parseInt(msg.properties.headers[RETRY_HEADER], 10) < options.retries
|
|
350
350
|
)
|
|
351
351
|
) {
|
|
352
352
|
await this.sendToQueue(queue, RabbitMq.parseMsg(msg).content, options, {
|
|
353
353
|
...msg.properties.headers,
|
|
354
|
-
[RETRY_HEADER]: msg.properties.headers
|
|
354
|
+
[RETRY_HEADER]: msg.properties.headers[RETRY_HEADER]
|
|
355
355
|
? msg.properties.headers[RETRY_HEADER] + 1
|
|
356
356
|
: 1,
|
|
357
357
|
});
|
|
@@ -359,7 +359,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
359
359
|
const deadQueue = `${queue}-dead`;
|
|
360
360
|
await this.sendToQueue(deadQueue, RabbitMq.parseMsg(msg).content, deadQueueOptions, {
|
|
361
361
|
...msg.properties.headers,
|
|
362
|
-
[RETRY_HEADER]: msg.properties.headers
|
|
362
|
+
[RETRY_HEADER]: msg.properties.headers[RETRY_HEADER]
|
|
363
363
|
? msg.properties.headers[RETRY_HEADER] + 1
|
|
364
364
|
: 1,
|
|
365
365
|
});
|
|
@@ -581,6 +581,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
581
581
|
throw e;
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
+
|
|
584
585
|
this.queues[queueName] = queue;
|
|
585
586
|
return queue;
|
|
586
587
|
}
|
|
@@ -685,7 +686,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
685
686
|
}
|
|
686
687
|
const channel = await this.getNewChannel({});
|
|
687
688
|
return channel.addSetup(async (confirmChannel: ConfirmChannel) => {
|
|
688
|
-
|
|
689
|
+
throw new Error('Dummy assertQueue error');
|
|
689
690
|
const q = await this.assertQueue(queue, optionsWithDefaults);
|
|
690
691
|
await confirmChannel.prefetch(limit, false);
|
|
691
692
|
const { consumerTag } = await confirmChannel.consume(
|
|
@@ -695,9 +696,9 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
695
696
|
return null;
|
|
696
697
|
}
|
|
697
698
|
|
|
698
|
-
const traceId = msg.properties.headers
|
|
699
|
-
const userId = msg.properties.headers
|
|
700
|
-
const automationId = msg.properties.headers
|
|
699
|
+
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
700
|
+
const userId = msg.properties.headers[USER_TRACING_HEADER];
|
|
701
|
+
const automationId = msg.properties.headers[AUTOMATION_ID_HEADER];
|
|
701
702
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
702
703
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
703
704
|
const trace = newTrace(traceTypes.RABBIT);
|
|
@@ -807,11 +808,11 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
807
808
|
const channelOld: ChannelWrapper = await this.getNewChannelOld({ name: `consume-exchange-${exchange}-queue-${queue}-old` });
|
|
808
809
|
await channelOld.addSetup(async (c: ConfirmChannel) => {
|
|
809
810
|
const assertExchange = await assertExchangeFanout(c, exchange);
|
|
810
|
-
|
|
811
|
+
await c.assertQueue(queue);
|
|
811
812
|
this.oldExchanges[exchange] = assertExchange;
|
|
812
813
|
await c.prefetch(limit, false);
|
|
813
814
|
return Promise.all([
|
|
814
|
-
|
|
815
|
+
c.bindQueue(queue, exchange, ''),
|
|
815
816
|
this.consumeOld(
|
|
816
817
|
queue,
|
|
817
818
|
callback,
|
|
@@ -935,9 +936,9 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
935
936
|
return null;
|
|
936
937
|
}
|
|
937
938
|
|
|
938
|
-
const traceId = msg.properties.headers
|
|
939
|
-
const userId = msg.properties.headers
|
|
940
|
-
const automationId = msg.properties.headers
|
|
939
|
+
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
940
|
+
const userId = msg.properties.headers[USER_TRACING_HEADER];
|
|
941
|
+
const automationId = msg.properties.headers[AUTOMATION_ID_HEADER];
|
|
941
942
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
942
943
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
943
944
|
const trace = newTrace(traceTypes.RABBIT);
|
|
@@ -1151,7 +1152,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
1151
1152
|
}
|
|
1152
1153
|
|
|
1153
1154
|
async setupQueueOld(queueName: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue> {
|
|
1154
|
-
|
|
1155
|
+
let queue: Replies.AssertQueue;
|
|
1155
1156
|
const shouldUseQuorum = RabbitMq.shouldUseQuorum(queueName);
|
|
1156
1157
|
const localeOptions = {
|
|
1157
1158
|
...options,
|
|
@@ -1165,9 +1166,9 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
1165
1166
|
try {
|
|
1166
1167
|
const channel: ChannelWrapper = await this.assertChannelOld();
|
|
1167
1168
|
debug('assertQueue->channel.addSetup', { queueName });
|
|
1168
|
-
|
|
1169
|
+
await channel.addSetup((setupChannel: ConfirmChannel) => setupChannel.assertQueue(queueName, localeOptions));
|
|
1169
1170
|
debug('assertQueue->channel.assertQueue', { queueName });
|
|
1170
|
-
|
|
1171
|
+
queue = await channel.assertQueue(queueName, localeOptions);
|
|
1171
1172
|
} catch (e) {
|
|
1172
1173
|
logger.error('rabbit: assertQueue error', { queueName, options, error: e });
|
|
1173
1174
|
if (!this.options?.dontRetryAssert) {
|
|
@@ -1178,18 +1179,12 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
1178
1179
|
debug('retrying assertQueue->channel.addSetup', { queueName });
|
|
1179
1180
|
await channel.addSetup((setupChannel: ConfirmChannel) => setupChannel.assertQueue(queueName, localeOptions));
|
|
1180
1181
|
debug('retrying assertQueue->channel.assertQueue', { queueName });
|
|
1181
|
-
|
|
1182
|
+
queue = await channel.assertQueue(queueName, localeOptions);
|
|
1182
1183
|
} else {
|
|
1183
1184
|
throw e;
|
|
1184
1185
|
}
|
|
1185
1186
|
}
|
|
1186
1187
|
|
|
1187
|
-
const queue = {
|
|
1188
|
-
queue: 'bla bla queue',
|
|
1189
|
-
messageCount: 0,
|
|
1190
|
-
consumerCount: 2,
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
1188
|
this.oldQueues[queueName] = queue;
|
|
1194
1189
|
return queue;
|
|
1195
1190
|
}
|