@onlineapps/conn-infra-mq 1.1.42 → 1.1.43

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-infra-mq",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "A promise-based, broker-agnostic client for sending and receiving messages via RabbitMQ",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -221,48 +221,11 @@ class RabbitMQClient extends EventEmitter {
221
221
  // Business queue - should already exist, skip checkQueue() to avoid channel closure
222
222
  console.log(`[RabbitMQClient] DEBUG: Business queue ${queue}, skipping checkQueue() in publish() - queue should already exist`);
223
223
  } else {
224
- // Infrastructure queue - use assertQueue() directly (idempotent, won't cause 406)
225
- // assertQueue() will use existing queue even if args differ, avoiding channel closure
226
- // Recreate queueChannel if it's closed
227
- if (!this._queueChannel || this._queueChannel.closed) {
228
- if (!this._connection) {
229
- throw new Error('Cannot assertQueue: connection is not available');
230
- }
231
- console.warn('[RabbitMQClient] Queue channel is closed, recreating...');
232
- try {
233
- if (this._queueChannel) {
234
- try {
235
- await this._queueChannel.close();
236
- } catch (err) {
237
- // Ignore errors when closing already-closed channel
238
- }
239
- }
240
- this._queueChannel = await this._connection.createChannel();
241
- this._queueChannel._createdAt = new Date().toISOString();
242
- this._queueChannel._closeReason = null;
243
- this._queueChannel._lastOperation = null;
244
- this._queueChannel.on('error', (err) => {
245
- console.error('[RabbitMQClient] Queue channel error:', err.message);
246
- this._queueChannel._closeReason = `Error: ${err.message} (code: ${err.code})`;
247
- });
248
- this._queueChannel.on('close', () => {
249
- console.error('[RabbitMQClient] Queue channel closed');
250
- });
251
- } catch (recreateErr) {
252
- console.warn(`[RabbitMQClient] Failed to recreate queue channel, proceeding anyway:`, recreateErr.message);
253
- }
254
- }
255
-
256
- const queueOptions = this._getQueueOptions(queue);
257
- try {
258
- if (this._queueChannel && !this._queueChannel.closed) {
259
- await this._queueChannel.assertQueue(queue, queueOptions);
260
- }
261
- } catch (assertErr) {
262
- // If assertQueue fails (shouldn't happen), log and proceed anyway
263
- // The queue likely exists with different args - publish will work or fail clearly
264
- console.warn(`[RabbitMQClient] assertQueue failed for ${queue}, proceeding anyway:`, assertErr.message);
265
- }
224
+ // Infrastructure queue - skip assertQueue() to avoid 406 channel closure
225
+ // Infrastructure queues are created by monitoring consumer at startup
226
+ // If queue doesn't exist, publish() will fail with a clear error
227
+ // This matches the pattern used for business queues - early creation, no runtime checks
228
+ console.log(`[RabbitMQClient] DEBUG: Infrastructure queue ${queue}, skipping assertQueue() - queue should already exist (created by monitoring consumer)`);
266
229
  }
267
230
  // Publish using ConfirmChannel (for publisher confirms)
268
231
  this._channel.sendToQueue(queue, buffer, { persistent, headers, routingKey });