@onlineapps/conn-orch-registry 1.1.16 → 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.16",
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
 
@@ -123,10 +123,20 @@ class ServiceRegistryClient extends EventEmitter {
123
123
  // Handle registration response from registry
124
124
  // Registry sends 'register.confirmed' after validation
125
125
  if ((payload.type === 'registerResponse' || payload.type === 'register.confirmed') && payload.requestId) {
126
+ console.log(`[RegistryClient] ${this.serviceName}: Received ${payload.type} message`, {
127
+ requestId: payload.requestId,
128
+ hasPendingRegistrations: !!(this.pendingRegistrations),
129
+ pendingCount: this.pendingRegistrations ? this.pendingRegistrations.size : 0,
130
+ hasMatchingRequest: !!(this.pendingRegistrations && this.pendingRegistrations.has(payload.requestId)),
131
+ pendingKeys: this.pendingRegistrations ? Array.from(this.pendingRegistrations.keys()) : []
132
+ });
133
+
126
134
  if (this.pendingRegistrations && this.pendingRegistrations.has(payload.requestId)) {
127
135
  const { resolve } = this.pendingRegistrations.get(payload.requestId);
128
136
  this.pendingRegistrations.delete(payload.requestId);
129
137
 
138
+ console.log(`[RegistryClient] ${this.serviceName}: ✓ Resolving registration promise for requestId: ${payload.requestId}`);
139
+
130
140
  // Resolve the registration promise with the response
131
141
  resolve({
132
142
  success: payload.success || false,
@@ -137,6 +147,8 @@ class ServiceRegistryClient extends EventEmitter {
137
147
  validated: payload.validated || payload.success, // Consider successful registration as validated
138
148
  certificate: payload.certificate || null // Include certificate from Registry
139
149
  });
150
+ } else {
151
+ console.warn(`[RegistryClient] ${this.serviceName}: ⚠️ Received ${payload.type} with requestId ${payload.requestId}, but no matching pending registration found`);
140
152
  }
141
153
  }
142
154
 
@@ -217,7 +229,15 @@ class ServiceRegistryClient extends EventEmitter {
217
229
  }
218
230
 
219
231
  // Send registration message to registry
220
- 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
+ }
221
241
  console.log(`[RegistryClient] ${this.serviceName}: Sending registration message to queue: ${this.registryQueue}`);
222
242
  console.log(`[RegistryClient] ${this.serviceName}: Message type: ${msg.type}, serviceName: ${msg.serviceName}, version: ${msg.version}`);
223
243
  this.queueManager.channel.sendToQueue(
@@ -257,7 +277,14 @@ class ServiceRegistryClient extends EventEmitter {
257
277
  };
258
278
 
259
279
  // Send deregistration message to registry
260
- 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
+ }
261
288
  this.queueManager.channel.sendToQueue(
262
289
  this.registryQueue,
263
290
  Buffer.from(JSON.stringify(msg)),
@@ -300,7 +327,14 @@ class ServiceRegistryClient extends EventEmitter {
300
327
  specificationEndpoint: this.specificationEndpoint,
301
328
  timestamp: new Date().toISOString()
302
329
  };
303
- 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
+ }
304
338
  this.queueManager.channel.sendToQueue(
305
339
  this.registryQueue,
306
340
  Buffer.from(JSON.stringify(msg)),
@@ -344,7 +378,14 @@ class ServiceRegistryClient extends EventEmitter {
344
378
  description: apiDescription,
345
379
  timestamp: new Date().toISOString()
346
380
  };
347
- 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
+ }
348
389
  this.queueManager.channel.sendToQueue(
349
390
  this.registryQueue,
350
391
  Buffer.from(JSON.stringify(msg)),