@onlineapps/conn-infra-mq 1.1.17 → 1.1.18
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 +35 -6
package/package.json
CHANGED
|
@@ -292,17 +292,46 @@ class QueueManager {
|
|
|
292
292
|
* @param {Object} options - Queue options
|
|
293
293
|
*/
|
|
294
294
|
async createTemporaryQueue(prefix = 'temp', options = {}) {
|
|
295
|
+
const transport = this.client._transport;
|
|
296
|
+
if (!transport || !transport.channel) {
|
|
297
|
+
throw new Error('MQ client not connected');
|
|
298
|
+
}
|
|
299
|
+
// Use queueChannel for queue operations
|
|
300
|
+
const channel = transport.queueChannel || transport.channel;
|
|
301
|
+
|
|
295
302
|
const queueName = `${prefix}.${Date.now()}.${Math.random().toString(36).substr(2, 9)}`;
|
|
296
303
|
|
|
297
|
-
|
|
304
|
+
// For temporary queues (rpc.reply.*), we MUST create them explicitly
|
|
305
|
+
// because they are used immediately for consuming replies
|
|
306
|
+
// Use assertQueue directly on queueChannel to avoid RPC reply queue issues
|
|
307
|
+
const queueOptions = {
|
|
298
308
|
durable: false,
|
|
309
|
+
exclusive: options.exclusive !== false, // Default to exclusive for temporary queues
|
|
299
310
|
autoDelete: true,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
311
|
+
arguments: {}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Add expires if specified
|
|
315
|
+
if (options.expires) {
|
|
316
|
+
queueOptions.arguments['x-expires'] = options.expires;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Check if channel is open before assertQueue
|
|
320
|
+
if (!channel || channel.closed) {
|
|
321
|
+
throw new Error('Channel is closed - cannot create temporary queue');
|
|
322
|
+
}
|
|
304
323
|
|
|
305
|
-
|
|
324
|
+
try {
|
|
325
|
+
await channel.assertQueue(queueName, queueOptions);
|
|
326
|
+
this.managedQueues.add(queueName);
|
|
327
|
+
return queueName;
|
|
328
|
+
} catch (assertErr) {
|
|
329
|
+
// If channel closed during assertQueue, throw descriptive error
|
|
330
|
+
if (!channel || channel.closed) {
|
|
331
|
+
throw new Error(`Channel closed during assertQueue for temporary queue ${queueName} - RPC reply queue issue detected`);
|
|
332
|
+
}
|
|
333
|
+
throw assertErr;
|
|
334
|
+
}
|
|
306
335
|
}
|
|
307
336
|
|
|
308
337
|
/**
|