@onlineapps/mq-client-core 1.0.7 → 1.0.8
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
|
@@ -252,8 +252,25 @@ class RabbitMQClient extends EventEmitter {
|
|
|
252
252
|
|
|
253
253
|
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] Asserting queue ${queue} before consume() at ${new Date().toISOString()}`);
|
|
254
254
|
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] Queue options:`, JSON.stringify(queueOptions, null, 2));
|
|
255
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] _queueChannel state: exists=${!!this._queueChannel}, closed=${this._queueChannel ? this._queueChannel.closed : 'N/A'}`);
|
|
255
256
|
|
|
257
|
+
// CRITICAL: Check if queue already exists with different arguments
|
|
258
|
+
// This can happen if sendToQueue() or amqplib's consume() auto-created it without TTL
|
|
256
259
|
try {
|
|
260
|
+
const queueInfo = await this._queueChannel.checkQueue(queue);
|
|
261
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] Queue ${queue} already exists with arguments:`, JSON.stringify(queueInfo.messageCount !== undefined ? { messageCount: queueInfo.messageCount, consumerCount: queueInfo.consumerCount } : queueInfo));
|
|
262
|
+
// If queue exists, we need to check if arguments match
|
|
263
|
+
// Note: checkQueue() doesn't return arguments, so we'll try assertQueue() and catch 406
|
|
264
|
+
} catch (checkErr) {
|
|
265
|
+
if (checkErr.code === 404) {
|
|
266
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] Queue ${queue} does not exist (404), will be created with options`);
|
|
267
|
+
} else {
|
|
268
|
+
console.warn(`[RabbitMQClient] [mq-client-core] [CONSUMER] checkQueue() failed for ${queue}:`, checkErr.message);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] About to call assertQueue(${queue}, ${JSON.stringify(queueOptions)})`);
|
|
257
274
|
await this._queueChannel.assertQueue(queue, queueOptions);
|
|
258
275
|
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] ✓ Queue ${queue} asserted successfully`);
|
|
259
276
|
} catch (assertErr) {
|
|
@@ -276,6 +293,13 @@ class RabbitMQClient extends EventEmitter {
|
|
|
276
293
|
this._channel.prefetch(prefetch);
|
|
277
294
|
}
|
|
278
295
|
|
|
296
|
+
// CRITICAL: Log before calling amqplib's consume()
|
|
297
|
+
// amqplib's consume() may internally call assertQueue() without parameters if queue doesn't exist
|
|
298
|
+
// This would create queue with default arguments (no TTL), causing 406 errors later
|
|
299
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] About to call amqplib's channel.consume(${queue})`);
|
|
300
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] ⚠ WARNING: amqplib's consume() may internally call assertQueue() WITHOUT parameters if queue doesn't exist`);
|
|
301
|
+
console.log(`[RabbitMQClient] [mq-client-core] [CONSUMER] ⚠ WARNING: We already asserted queue with correct parameters above - this should prevent auto-creation`);
|
|
302
|
+
|
|
279
303
|
await this._channel.consume(
|
|
280
304
|
queue,
|
|
281
305
|
async (msg) => {
|