@onlineapps/mq-client-core 1.0.25 → 1.0.27

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.25",
3
+ "version": "1.0.27",
4
4
  "description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -129,6 +129,58 @@ module.exports = {
129
129
  }
130
130
  },
131
131
 
132
+ /**
133
+ * Monitoring infrastructure queue configurations
134
+ * These are dedicated queues for Monitoring service (separate from delivery queues)
135
+ */
136
+ monitoring: {
137
+ /**
138
+ * monitoring.workflow.completed - Completed workflows for monitoring
139
+ * Business services publish here for observability (separate from workflow.completed for delivery)
140
+ */
141
+ 'workflow.completed': {
142
+ durable: true,
143
+ arguments: {
144
+ 'x-message-ttl': 300000, // 5 minutes TTL
145
+ 'x-max-length': 10000
146
+ }
147
+ },
148
+
149
+ /**
150
+ * monitoring.workflow.failed - Failed workflows for monitoring
151
+ * Business services publish here for observability (separate from workflow.failed for delivery)
152
+ */
153
+ 'workflow.failed': {
154
+ durable: true,
155
+ arguments: {
156
+ 'x-message-ttl': 300000, // 5 minutes TTL
157
+ 'x-max-length': 10000
158
+ }
159
+ },
160
+
161
+ /**
162
+ * monitoring.registry.events - Registry events for monitoring
163
+ */
164
+ 'registry.events': {
165
+ durable: true,
166
+ arguments: {
167
+ 'x-message-ttl': 60000, // 1 minute TTL
168
+ 'x-max-length': 5000
169
+ }
170
+ },
171
+
172
+ /**
173
+ * monitoring.service.heartbeats - Service heartbeats for monitoring
174
+ */
175
+ 'service.heartbeats': {
176
+ durable: true,
177
+ arguments: {
178
+ 'x-message-ttl': 120000, // 2 minutes TTL
179
+ 'x-max-length': 10000
180
+ }
181
+ }
182
+ },
183
+
132
184
  /**
133
185
  * Registry infrastructure queue configurations
134
186
  */
@@ -213,10 +265,11 @@ module.exports = {
213
265
  * @returns {boolean} True if infrastructure queue
214
266
  */
215
267
  isInfrastructureQueue(queueName) {
216
- return queueName.startsWith('workflow.') ||
217
- queueName.startsWith('registry.') ||
268
+ return queueName.startsWith('workflow.') ||
269
+ queueName.startsWith('registry.') ||
218
270
  queueName.startsWith('infrastructure.') ||
219
- queueName.startsWith('validation.');
271
+ queueName.startsWith('validation.') ||
272
+ queueName.startsWith('monitoring.');
220
273
  },
221
274
 
222
275
  /**
@@ -288,9 +341,22 @@ module.exports = {
288
341
  return this.getQueueConfig('infrastructure', name);
289
342
  },
290
343
 
344
+ /**
345
+ * Get monitoring queue configuration
346
+ * @param {string} queueName - Queue name (e.g., 'monitoring.workflow.completed')
347
+ * @returns {Object} Queue configuration
348
+ */
349
+ getMonitoringQueueConfig(queueName) {
350
+ if (!queueName.startsWith('monitoring.')) {
351
+ throw new Error(`Queue ${queueName} is not a monitoring queue`);
352
+ }
353
+ const name = queueName.replace('monitoring.', '');
354
+ return this.getQueueConfig('monitoring', name);
355
+ },
356
+
291
357
  /**
292
358
  * Get infrastructure queue configuration by queue name (auto-detect type)
293
- * @param {string} queueName - Full queue name (e.g., 'workflow.init', 'registry.register', 'infrastructure.health.checks')
359
+ * @param {string} queueName - Full queue name (e.g., 'workflow.init', 'registry.register', 'infrastructure.health.checks', 'monitoring.workflow.completed')
294
360
  * @returns {Object} Queue configuration
295
361
  */
296
362
  getInfrastructureQueueConfig(queueName) {
@@ -300,8 +366,10 @@ module.exports = {
300
366
  return this.getRegistryQueueConfig(queueName);
301
367
  } else if (queueName.startsWith('infrastructure.')) {
302
368
  return this.getInfrastructureHealthQueueConfig(queueName);
369
+ } else if (queueName.startsWith('monitoring.')) {
370
+ return this.getMonitoringQueueConfig(queueName);
303
371
  } else {
304
- throw new Error(`Queue ${queueName} is not an infrastructure queue. Infrastructure queues must start with 'workflow.', 'registry.', or 'infrastructure.'`);
372
+ throw new Error(`Queue ${queueName} is not an infrastructure queue. Infrastructure queues must start with 'workflow.', 'registry.', 'infrastructure.', or 'monitoring.'`);
305
373
  }
306
374
  }
307
375
  };
@@ -185,11 +185,23 @@ class RabbitMQClient extends EventEmitter {
185
185
  // Queue exists - proceed to publish
186
186
  } catch (checkErr) {
187
187
  // If queue doesn't exist (404), this is an ERROR for infrastructure queues
188
- // Infrastructure queues (workflow.*, registry.*) must be created explicitly with correct arguments
188
+ // Infrastructure queues (workflow.*, registry.*, infrastructure.*, monitoring.*, validation.*) must be created explicitly with correct arguments
189
189
  // We should NOT auto-create them here, as we don't have access to queueConfig in mq-client-core
190
190
  if (checkErr.code === 404) {
191
- // Check if this is an infrastructure queue
192
- const isInfraQueue = queue.startsWith('workflow.') || queue.startsWith('registry.');
191
+ // Check if this is an infrastructure queue using queueConfig
192
+ let isInfraQueue = false;
193
+ try {
194
+ const queueConfig = require('../config/queueConfig');
195
+ isInfraQueue = queueConfig.isInfrastructureQueue(queue);
196
+ } catch (requireErr) {
197
+ // Fallback to pattern matching if queueConfig not available
198
+ isInfraQueue = queue.startsWith('workflow.') ||
199
+ queue.startsWith('registry.') ||
200
+ queue.startsWith('infrastructure.') ||
201
+ queue.startsWith('monitoring.') ||
202
+ queue.startsWith('validation.');
203
+ }
204
+
193
205
  if (isInfraQueue) {
194
206
  throw new Error(`Cannot publish to infrastructure queue ${queue}: queue does not exist. Infrastructure queues must be created explicitly with correct arguments (TTL, max-length, etc.) before publishing.`);
195
207
  }