@onlineapps/mq-client-core 1.0.1 → 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
|
@@ -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
|
-
//
|
|
125
|
-
//
|
|
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
|
-
|
|
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
|