@onlineapps/conn-infra-mq 1.1.28 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-infra-mq",
3
- "version": "1.1.28",
3
+ "version": "1.1.29",
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": {
@@ -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
- // Use queueChannel (regular channel) for queue operations to avoid RPC reply queue issues
158
- // Use central config for infrastructure queues
159
- const queueOptions = this._getQueueOptions(queue);
160
- try {
161
- await this._queueChannel.checkQueue(queue);
162
- // Queue exists - proceed to publish
163
- } catch (checkErr) {
164
- // If queue doesn't exist (404), create it
165
- if (checkErr.code === 404) {
166
- await this._queueChannel.assertQueue(queue, queueOptions);
167
- } else {
168
- // Other error (including 406) - queue exists with different args, proceed
169
- console.warn(`[RabbitMQClient] Queue ${queue} exists with different arguments, using as-is`);
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)