@onlineapps/mq-client-core 1.0.0 → 1.0.2

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/mq-client-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -29,4 +29,3 @@
29
29
  "access": "public"
30
30
  }
31
31
  }
32
-
@@ -40,8 +40,11 @@ module.exports = {
40
40
  type: 'boolean',
41
41
  },
42
42
  logger: {
43
- type: 'object',
44
- description: 'Custom logger with methods: info, warn, error, debug',
43
+ oneOf: [
44
+ { type: 'null' },
45
+ { type: 'object' }
46
+ ],
47
+ description: 'Custom logger with methods: info, warn, error, debug (can be null)',
45
48
  },
46
49
  },
47
50
  required: ['type', 'host'], // Only type and host required
@@ -121,10 +121,22 @@ class RabbitMQClient extends EventEmitter {
121
121
  try {
122
122
  // Ensure queue exists if publishing directly to queue and using default exchange
123
123
  if (!exchange) {
124
- // Simple queue assertion - infrastructure services should ensure queues exist
125
- // If queue doesn't exist, assertQueue will create it with default options
124
+ // For infrastructure queues, they should already exist with specific arguments
125
+ // Try to check if queue exists first, if not, create with default options
126
+ // If it exists with different args (406), use it as-is
126
127
  const queueOptions = options.queueOptions || { durable: this._config.durable };
127
- await this._channel.assertQueue(queue, queueOptions);
128
+ try {
129
+ await this._channel.assertQueue(queue, queueOptions);
130
+ } catch (assertErr) {
131
+ // If queue exists with different arguments (406), use it as-is
132
+ if (assertErr.code === 406) {
133
+ console.warn(`[RabbitMQClient] Queue ${queue} exists with different arguments, using as-is:`, assertErr.message);
134
+ // Don't try to re-assert - just proceed to publish
135
+ } else {
136
+ // Other error - rethrow
137
+ throw assertErr;
138
+ }
139
+ }
128
140
  this._channel.sendToQueue(queue, buffer, { persistent, headers, routingKey });
129
141
  } else {
130
142
  // If exchange is specified, assert exchange and publish to it