@onlineapps/conn-infra-mq 1.1.4 → 1.1.5
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/transports/rabbitmqClient.js +19 -11
package/package.json
CHANGED
|
@@ -163,19 +163,27 @@ class RabbitMQClient extends EventEmitter {
|
|
|
163
163
|
// Use central config for infrastructure queues
|
|
164
164
|
const queueOptions = this._getQueueOptions(queue, { durable });
|
|
165
165
|
|
|
166
|
-
// Try to
|
|
166
|
+
// Try to assert queue with our config
|
|
167
|
+
// If it fails with 406 (PRECONDITION-FAILED), queue exists with different args - use it as-is
|
|
167
168
|
try {
|
|
168
|
-
await this._channel.
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
await this._channel.assertQueue(queue, queueOptions);
|
|
170
|
+
} catch (assertErr) {
|
|
171
|
+
// If queue exists with different arguments (406), use it as-is
|
|
172
|
+
if (assertErr.code === 406) {
|
|
173
|
+
console.warn(`[RabbitMQClient] Queue ${queue} exists with different arguments, using as-is:`, assertErr.message);
|
|
174
|
+
// Try to assert with minimal options (just durable) to verify queue exists
|
|
175
|
+
try {
|
|
176
|
+
await this._channel.assertQueue(queue, { durable: durable !== false });
|
|
177
|
+
} catch (minErr) {
|
|
178
|
+
// If even minimal assert fails, queue might not exist - log and proceed
|
|
179
|
+
console.warn(`[RabbitMQClient] Could not assert queue ${queue} with minimal options:`, minErr.message);
|
|
180
|
+
}
|
|
181
|
+
} else if (assertErr.code === 404) {
|
|
182
|
+
// Queue doesn't exist - this shouldn't happen with assertQueue, but handle it
|
|
183
|
+
throw assertErr;
|
|
175
184
|
} else {
|
|
176
|
-
// Other error
|
|
177
|
-
|
|
178
|
-
console.warn(`[RabbitMQClient] Queue ${queue} exists with different arguments, using as-is:`, checkErr.message);
|
|
185
|
+
// Other error - rethrow
|
|
186
|
+
throw assertErr;
|
|
179
187
|
}
|
|
180
188
|
}
|
|
181
189
|
}
|