@grupodiariodaregiao/bunstone 0.4.6 → 0.4.7
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 +16 -2
- package/lib/app-startup.ts +31 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -118183,6 +118183,13 @@ if (document.readyState === 'loading') {
|
|
|
118183
118183
|
return raw.content.toString();
|
|
118184
118184
|
}
|
|
118185
118185
|
})();
|
|
118186
|
+
const xDeath = raw.properties.headers?.["x-death"];
|
|
118187
|
+
const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
|
|
118188
|
+
const isDlqQueue = queueName.toLowerCase().includes(".dlq");
|
|
118189
|
+
if ((isDlqQueue || descriptor.options.queue?.toLowerCase().includes(".dlq")) && !isDeadLetter) {
|
|
118190
|
+
channel.ack(raw);
|
|
118191
|
+
return;
|
|
118192
|
+
}
|
|
118186
118193
|
const msg = {
|
|
118187
118194
|
data,
|
|
118188
118195
|
raw,
|
|
@@ -118195,7 +118202,7 @@ if (document.readyState === 'loading') {
|
|
|
118195
118202
|
} catch (err) {
|
|
118196
118203
|
AppStartup.logger.error(`Unhandled error in RabbitMQ handler ${providerClass.name}.${descriptor.methodName}() on exchange "${exchange}" routingKey "${routingKey}": ${err.message}`);
|
|
118197
118204
|
if (!noAck) {
|
|
118198
|
-
channel.nack(raw, false,
|
|
118205
|
+
channel.nack(raw, false, false);
|
|
118199
118206
|
}
|
|
118200
118207
|
}
|
|
118201
118208
|
}, { noAck });
|
|
@@ -118238,6 +118245,13 @@ if (document.readyState === 'loading') {
|
|
|
118238
118245
|
return raw.content.toString();
|
|
118239
118246
|
}
|
|
118240
118247
|
})();
|
|
118248
|
+
const xDeath = raw.properties.headers?.["x-death"];
|
|
118249
|
+
const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
|
|
118250
|
+
const isDlqQueue = queue2.toLowerCase().includes(".dlq");
|
|
118251
|
+
if (isDlqQueue && !isDeadLetter) {
|
|
118252
|
+
channel.ack(raw);
|
|
118253
|
+
return;
|
|
118254
|
+
}
|
|
118241
118255
|
let settled = false;
|
|
118242
118256
|
const settle = (fn3) => {
|
|
118243
118257
|
if (!settled) {
|
|
@@ -118267,7 +118281,7 @@ if (document.readyState === 'loading') {
|
|
|
118267
118281
|
} catch (err) {
|
|
118268
118282
|
AppStartup.logger.error(`Unhandled error in RabbitMQ handler ${providerName}.${descriptor.methodName}() on queue "${queue2}": ${err.message}`);
|
|
118269
118283
|
if (!handlerNoAck && !settled) {
|
|
118270
|
-
settle(() => channel.nack(raw, false,
|
|
118284
|
+
settle(() => channel.nack(raw, false, false));
|
|
118271
118285
|
}
|
|
118272
118286
|
}
|
|
118273
118287
|
}
|
package/lib/app-startup.ts
CHANGED
|
@@ -1080,6 +1080,24 @@ if (document.readyState === 'loading') {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
})();
|
|
1082
1082
|
|
|
1083
|
+
const xDeath = raw.properties.headers?.["x-death"];
|
|
1084
|
+
const isDeadLetter =
|
|
1085
|
+
Array.isArray(xDeath) && xDeath.length > 0;
|
|
1086
|
+
const isDlqQueue = queueName.toLowerCase().includes(".dlq");
|
|
1087
|
+
|
|
1088
|
+
// If the handler is on a DLQ or uses DeadLetterMessage type,
|
|
1089
|
+
// only process messages that have x-death headers.
|
|
1090
|
+
if (
|
|
1091
|
+
(isDlqQueue ||
|
|
1092
|
+
descriptor.options.queue
|
|
1093
|
+
?.toLowerCase()
|
|
1094
|
+
.includes(".dlq")) &&
|
|
1095
|
+
!isDeadLetter
|
|
1096
|
+
) {
|
|
1097
|
+
channel.ack(raw);
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1083
1101
|
const msg: RabbitMessage = {
|
|
1084
1102
|
data,
|
|
1085
1103
|
raw,
|
|
@@ -1095,7 +1113,7 @@ if (document.readyState === 'loading') {
|
|
|
1095
1113
|
`Unhandled error in RabbitMQ handler ${providerClass.name}.${descriptor.methodName}() on exchange "${exchange}" routingKey "${routingKey}": ${err.message}`,
|
|
1096
1114
|
);
|
|
1097
1115
|
if (!noAck) {
|
|
1098
|
-
channel.nack(raw, false,
|
|
1116
|
+
channel.nack(raw, false, false);
|
|
1099
1117
|
}
|
|
1100
1118
|
}
|
|
1101
1119
|
},
|
|
@@ -1161,6 +1179,17 @@ if (document.readyState === 'loading') {
|
|
|
1161
1179
|
}
|
|
1162
1180
|
})();
|
|
1163
1181
|
|
|
1182
|
+
const xDeath = raw.properties.headers?.["x-death"];
|
|
1183
|
+
const isDeadLetter = Array.isArray(xDeath) && xDeath.length > 0;
|
|
1184
|
+
const isDlqQueue = queue.toLowerCase().includes(".dlq");
|
|
1185
|
+
|
|
1186
|
+
// If this is a DLQ, skip messages that don't have x-death headers
|
|
1187
|
+
// (i.e. someone published directly to the DLQ instead of it being a failed message)
|
|
1188
|
+
if (isDlqQueue && !isDeadLetter) {
|
|
1189
|
+
channel.ack(raw);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1164
1193
|
// Settle guard: ack/nack/reject may only be called once per
|
|
1165
1194
|
// delivery tag regardless of how many handlers invoke it.
|
|
1166
1195
|
let settled = false;
|
|
@@ -1204,7 +1233,7 @@ if (document.readyState === 'loading') {
|
|
|
1204
1233
|
`Unhandled error in RabbitMQ handler ${providerName}.${descriptor.methodName}() on queue "${queue}": ${err.message}`,
|
|
1205
1234
|
);
|
|
1206
1235
|
if (!handlerNoAck && !settled) {
|
|
1207
|
-
settle(() => channel.nack(raw, false,
|
|
1236
|
+
settle(() => channel.nack(raw, false, false));
|
|
1208
1237
|
}
|
|
1209
1238
|
}
|
|
1210
1239
|
}
|