@onlineapps/conn-infra-mq 1.1.24 → 1.1.26
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
CHANGED
|
@@ -298,31 +298,36 @@ class QueueManager {
|
|
|
298
298
|
try {
|
|
299
299
|
// Check if channel is still open before each operation
|
|
300
300
|
if (!channel || channel.closed) {
|
|
301
|
+
console.error(`[QueueManager] DEBUG: Channel closed before creating ${queueName}`);
|
|
301
302
|
throw new Error(`Channel closed before creating ${queueName} - cannot continue`);
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
console.log(`[QueueManager] DEBUG: About to assertQueue ${queueName} with options:`, JSON.stringify(queueOptions, null, 2));
|
|
306
|
+
console.log(`[QueueManager] DEBUG: Channel state before assertQueue: closed=${channel.closed}`);
|
|
307
|
+
|
|
304
308
|
await channel.assertQueue(queueName, queueOptions);
|
|
309
|
+
|
|
310
|
+
console.log(`[QueueManager] DEBUG: assertQueue succeeded for ${queueName}, channel closed=${channel.closed}`);
|
|
305
311
|
queues[queueInfo.type] = queueName;
|
|
306
312
|
console.info(`[QueueManager] ✓ Created business queue: ${queueName}`);
|
|
307
313
|
} catch (assertErr) {
|
|
314
|
+
console.error(`[QueueManager] DEBUG: assertQueue failed for ${queueName}:`, assertErr.message);
|
|
315
|
+
console.error(`[QueueManager] DEBUG: Error code: ${assertErr.code}, channel closed: ${channel ? channel.closed : 'N/A'}`);
|
|
316
|
+
console.error(`[QueueManager] DEBUG: Stack trace:`, assertErr.stack);
|
|
317
|
+
|
|
308
318
|
// If channel closed, this is a critical error
|
|
309
319
|
if (!channel || channel.closed) {
|
|
320
|
+
console.error(`[QueueManager] DEBUG: Channel was closed during assertQueue for ${queueName}`);
|
|
310
321
|
throw new Error(`Channel closed during assertQueue for ${queueName} - cannot create remaining queues`);
|
|
311
322
|
}
|
|
312
323
|
|
|
313
324
|
// If 406 PRECONDITION-FAILED, queue exists with different args - use it as-is
|
|
325
|
+
// CRITICAL: Do NOT use checkQueue() here - it closes channel on 404!
|
|
326
|
+
// If assertQueue() returned 406, queue exists (just with different args) - that's OK
|
|
314
327
|
if (assertErr.code === 406) {
|
|
315
328
|
console.warn(`[QueueManager] Queue ${queueName} exists with different arguments, using as-is:`, assertErr.message);
|
|
316
|
-
//
|
|
317
|
-
|
|
318
|
-
throw new Error(`Channel closed after 406 error for ${queueName}`);
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
await channel.checkQueue(queueName);
|
|
322
|
-
queues[queueInfo.type] = queueName;
|
|
323
|
-
} catch (checkErr) {
|
|
324
|
-
throw new Error(`Failed to verify existing queue ${queueName}: ${checkErr.message}`);
|
|
325
|
-
}
|
|
329
|
+
// Queue exists (just with different args) - accept it
|
|
330
|
+
queues[queueInfo.type] = queueName;
|
|
326
331
|
} else {
|
|
327
332
|
// Other error - critical, cannot continue
|
|
328
333
|
throw new Error(`Failed to create business queue ${queueName}: ${assertErr.message}`);
|
|
@@ -80,10 +80,12 @@ class RabbitMQClient extends EventEmitter {
|
|
|
80
80
|
this._queueChannel = await this._connection.createChannel();
|
|
81
81
|
this._queueChannel.on('error', (err) => {
|
|
82
82
|
// Log but don't emit - queue channel errors are less critical
|
|
83
|
-
console.
|
|
83
|
+
console.error('[RabbitMQClient] Queue channel error:', err.message);
|
|
84
|
+
console.error('[RabbitMQClient] Stack trace:', new Error().stack);
|
|
84
85
|
});
|
|
85
86
|
this._queueChannel.on('close', () => {
|
|
86
|
-
console.
|
|
87
|
+
console.error('[RabbitMQClient] Queue channel closed');
|
|
88
|
+
console.error('[RabbitMQClient] Stack trace at close:', new Error().stack);
|
|
87
89
|
});
|
|
88
90
|
} catch (err) {
|
|
89
91
|
// Cleanup partially created resources
|