@onlineapps/conn-infra-mq 1.1.33 → 1.1.34
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/package.json +1 -1
- package/src/layers/QueueManager.js +27 -0
package/package.json
CHANGED
|
@@ -245,7 +245,34 @@ class QueueManager {
|
|
|
245
245
|
|
|
246
246
|
// CRITICAL: Create ALL queues using assertQueue directly (no checkQueue first to avoid channel closure)
|
|
247
247
|
// This ensures all queues are created atomically
|
|
248
|
+
// IMPORTANT: Channel may be closed on 406, so we need to check and recreate it before each queue
|
|
248
249
|
for (const queueInfo of queueNames) {
|
|
250
|
+
// CRITICAL: Check if channel is closed before each queue operation (may have been closed by previous 406)
|
|
251
|
+
// Channel closes SYNCHRONOUSLY on 406, so we must check before each assertQueue
|
|
252
|
+
if (!channel) {
|
|
253
|
+
console.warn(`[QueueManager] DEBUG: Channel is null before ${queueInfo.name}, recreating...`);
|
|
254
|
+
channel = await transport._connection.createChannel();
|
|
255
|
+
transport.queueChannel = channel;
|
|
256
|
+
console.log(`[QueueManager] DEBUG: Channel recreated (was null) before ${queueInfo.name}`);
|
|
257
|
+
} else {
|
|
258
|
+
// Check if channel is closed - amqplib may set closed property or throw on use
|
|
259
|
+
try {
|
|
260
|
+
// Try a no-op to see if channel is usable
|
|
261
|
+
if (channel.closed === true) {
|
|
262
|
+
console.warn(`[QueueManager] DEBUG: Channel is closed before ${queueInfo.name}, recreating...`);
|
|
263
|
+
channel = await transport._connection.createChannel();
|
|
264
|
+
transport.queueChannel = channel;
|
|
265
|
+
console.log(`[QueueManager] DEBUG: Channel recreated (was closed) before ${queueInfo.name}`);
|
|
266
|
+
}
|
|
267
|
+
} catch (checkErr) {
|
|
268
|
+
// Channel may throw on access if closed - recreate it
|
|
269
|
+
console.warn(`[QueueManager] DEBUG: Channel check failed before ${queueInfo.name}, recreating...`);
|
|
270
|
+
channel = await transport._connection.createChannel();
|
|
271
|
+
transport.queueChannel = channel;
|
|
272
|
+
console.log(`[QueueManager] DEBUG: Channel recreated (check failed) before ${queueInfo.name}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
249
276
|
const queueName = queueInfo.name;
|
|
250
277
|
let queueOptions;
|
|
251
278
|
|