@onlineapps/conn-infra-mq 1.1.27 → 1.1.29
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 +23 -13
package/package.json
CHANGED
|
@@ -154,19 +154,29 @@ class RabbitMQClient extends EventEmitter {
|
|
|
154
154
|
try {
|
|
155
155
|
// Ensure queue exists if publishing directly to queue and using default exchange
|
|
156
156
|
if (!exchange) {
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
// CRITICAL: For business queues, do NOT use checkQueue() - it closes channel on 404!
|
|
158
|
+
// Business queues should already be created by setupServiceQueues() BEFORE publish is called
|
|
159
|
+
// If queue doesn't exist, that's a programming error - just proceed to publish
|
|
160
|
+
// publish() will fail with a clear error if queue doesn't exist
|
|
161
|
+
const isBusinessQueue = queueConfig.isBusinessQueue(queue);
|
|
162
|
+
|
|
163
|
+
if (isBusinessQueue) {
|
|
164
|
+
// Business queue - should already exist, skip checkQueue() to avoid channel closure
|
|
165
|
+
console.log(`[RabbitMQClient] DEBUG: Business queue ${queue}, skipping checkQueue() in publish() - queue should already exist`);
|
|
166
|
+
} else {
|
|
167
|
+
// Infrastructure queue - check if it exists
|
|
168
|
+
const queueOptions = this._getQueueOptions(queue);
|
|
169
|
+
try {
|
|
170
|
+
await this._queueChannel.checkQueue(queue);
|
|
171
|
+
// Queue exists - proceed to publish
|
|
172
|
+
} catch (checkErr) {
|
|
173
|
+
// If queue doesn't exist (404), create it
|
|
174
|
+
if (checkErr.code === 404) {
|
|
175
|
+
await this._queueChannel.assertQueue(queue, queueOptions);
|
|
176
|
+
} else {
|
|
177
|
+
// Other error (including 406) - queue exists with different args, proceed
|
|
178
|
+
console.warn(`[RabbitMQClient] Queue ${queue} exists with different arguments, using as-is`);
|
|
179
|
+
}
|
|
170
180
|
}
|
|
171
181
|
}
|
|
172
182
|
// Publish using ConfirmChannel (for publisher confirms)
|