@onlineapps/conn-orch-registry 1.1.17 → 1.1.19
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/queueManager.js +17 -1
- package/src/registryClient.js +33 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-registry",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
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": [
|
package/src/queueManager.js
CHANGED
|
@@ -43,6 +43,8 @@ class QueueManager {
|
|
|
43
43
|
*/
|
|
44
44
|
async init() {
|
|
45
45
|
this.conn = await amqp.connect(this.amqpUrl);
|
|
46
|
+
// Use regular channel instead of ConfirmChannel to avoid RPC reply queue issues
|
|
47
|
+
// ConfirmChannel uses RPC pattern which requires reply queues that may not exist
|
|
46
48
|
this.channel = await this.conn.createChannel();
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -65,7 +67,21 @@ class QueueManager {
|
|
|
65
67
|
const queuesToCreate = baseQueues.concat(additionalQueues);
|
|
66
68
|
|
|
67
69
|
for (const q of queuesToCreate) {
|
|
68
|
-
|
|
70
|
+
// Use checkQueue first to avoid 406 PRECONDITION-FAILED closing the channel
|
|
71
|
+
// If queue doesn't exist (404), then assertQueue to create it
|
|
72
|
+
try {
|
|
73
|
+
await this.channel.checkQueue(q);
|
|
74
|
+
// Queue exists - continue
|
|
75
|
+
} catch (checkErr) {
|
|
76
|
+
// If queue doesn't exist (404), create it with default options
|
|
77
|
+
if (checkErr.code === 404) {
|
|
78
|
+
await this.channel.assertQueue(q, { durable: true });
|
|
79
|
+
} else {
|
|
80
|
+
// Other error (including 406) - queue exists with different args
|
|
81
|
+
// Log warning and continue without asserting
|
|
82
|
+
console.warn(`[QueueManager] Queue ${q} exists with different arguments, using as-is:`, checkErr.message);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
|
package/src/registryClient.js
CHANGED
|
@@ -229,7 +229,15 @@ class ServiceRegistryClient extends EventEmitter {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// Send registration message to registry
|
|
232
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)),
|