@onlineapps/conn-orch-registry 1.1.17 → 1.1.18

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-orch-registry",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "license": "MIT",
5
5
  "description": "Connector-registry-client provides the core communication mechanism for microservices in this environment. It enables them to interact with a services_registry to receive and fulfill tasks by submitting heartbeats or their API descriptions.",
6
6
  "keywords": [
@@ -65,7 +65,21 @@ class QueueManager {
65
65
  const queuesToCreate = baseQueues.concat(additionalQueues);
66
66
 
67
67
  for (const q of queuesToCreate) {
68
- await this.channel.assertQueue(q, { durable: true });
68
+ // Use checkQueue first to avoid 406 PRECONDITION-FAILED closing the channel
69
+ // If queue doesn't exist (404), then assertQueue to create it
70
+ try {
71
+ await this.channel.checkQueue(q);
72
+ // Queue exists - continue
73
+ } catch (checkErr) {
74
+ // If queue doesn't exist (404), create it with default options
75
+ if (checkErr.code === 404) {
76
+ await this.channel.assertQueue(q, { durable: true });
77
+ } else {
78
+ // Other error (including 406) - queue exists with different args
79
+ // Log warning and continue without asserting
80
+ console.warn(`[QueueManager] Queue ${q} exists with different arguments, using as-is:`, checkErr.message);
81
+ }
82
+ }
69
83
  }
70
84
  }
71
85
 
@@ -229,7 +229,15 @@ class ServiceRegistryClient extends EventEmitter {
229
229
  }
230
230
 
231
231
  // Send registration message to registry
232
- await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
232
+ // Use checkQueue to avoid 406 PRECONDITION-FAILED closing the channel
233
+ try {
234
+ await this.queueManager.channel.checkQueue(this.registryQueue);
235
+ } catch (checkErr) {
236
+ if (checkErr.code === 404) {
237
+ await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
238
+ }
239
+ // If 406 or other error, queue exists - proceed to publish
240
+ }
233
241
  console.log(`[RegistryClient] ${this.serviceName}: Sending registration message to queue: ${this.registryQueue}`);
234
242
  console.log(`[RegistryClient] ${this.serviceName}: Message type: ${msg.type}, serviceName: ${msg.serviceName}, version: ${msg.version}`);
235
243
  this.queueManager.channel.sendToQueue(
@@ -269,7 +277,14 @@ class ServiceRegistryClient extends EventEmitter {
269
277
  };
270
278
 
271
279
  // Send deregistration message to registry
272
- await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
280
+ // Use checkQueue to avoid 406 PRECONDITION-FAILED closing the channel
281
+ try {
282
+ await this.queueManager.channel.checkQueue(this.registryQueue);
283
+ } catch (checkErr) {
284
+ if (checkErr.code === 404) {
285
+ await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
286
+ }
287
+ }
273
288
  this.queueManager.channel.sendToQueue(
274
289
  this.registryQueue,
275
290
  Buffer.from(JSON.stringify(msg)),
@@ -312,7 +327,14 @@ class ServiceRegistryClient extends EventEmitter {
312
327
  specificationEndpoint: this.specificationEndpoint,
313
328
  timestamp: new Date().toISOString()
314
329
  };
315
- await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
330
+ // Use checkQueue to avoid 406 PRECONDITION-FAILED closing the channel
331
+ try {
332
+ await this.queueManager.channel.checkQueue(this.registryQueue);
333
+ } catch (checkErr) {
334
+ if (checkErr.code === 404) {
335
+ await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
336
+ }
337
+ }
316
338
  this.queueManager.channel.sendToQueue(
317
339
  this.registryQueue,
318
340
  Buffer.from(JSON.stringify(msg)),
@@ -356,7 +378,14 @@ class ServiceRegistryClient extends EventEmitter {
356
378
  description: apiDescription,
357
379
  timestamp: new Date().toISOString()
358
380
  };
359
- await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
381
+ // Use checkQueue to avoid 406 PRECONDITION-FAILED closing the channel
382
+ try {
383
+ await this.queueManager.channel.checkQueue(this.registryQueue);
384
+ } catch (checkErr) {
385
+ if (checkErr.code === 404) {
386
+ await this.queueManager.channel.assertQueue(this.registryQueue, { durable: true });
387
+ }
388
+ }
360
389
  this.queueManager.channel.sendToQueue(
361
390
  this.registryQueue,
362
391
  Buffer.from(JSON.stringify(msg)),