@onlineapps/conn-orch-registry 1.1.18 → 1.1.20
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 +2 -0
- package/src/registryClient.js +39 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-registry",
|
|
3
|
-
|
|
3
|
+
"version": "1.1.20",
|
|
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
|
|
package/src/registryClient.js
CHANGED
|
@@ -84,14 +84,28 @@ class ServiceRegistryClient extends EventEmitter {
|
|
|
84
84
|
// Start consuming service response queue for registry responses
|
|
85
85
|
await this.queueManager.channel.consume(
|
|
86
86
|
this.serviceResponseQueue,
|
|
87
|
-
msg =>
|
|
87
|
+
msg => {
|
|
88
|
+
// Handle null message (queue deleted, connection closed, consumer canceled)
|
|
89
|
+
if (!msg) {
|
|
90
|
+
console.warn(`[RegistryClient] ${this.serviceName}: Received null message from ${this.serviceResponseQueue} (queue may be deleted or connection closed)`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this._handleRegistryMessage(msg);
|
|
94
|
+
},
|
|
88
95
|
{ noAck: false }
|
|
89
96
|
);
|
|
90
97
|
|
|
91
98
|
// CRITICAL: Also listen on registry event queue for certificate delivery
|
|
92
99
|
await this.queueManager.channel.consume(
|
|
93
100
|
this.serviceRegistryQueue,
|
|
94
|
-
msg =>
|
|
101
|
+
msg => {
|
|
102
|
+
// Handle null message (queue deleted, connection closed, consumer canceled)
|
|
103
|
+
if (!msg) {
|
|
104
|
+
console.warn(`[RegistryClient] ${this.serviceName}: Received null message from ${this.serviceRegistryQueue} (queue may be deleted or connection closed)`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this._handleRegistryMessage(msg);
|
|
108
|
+
},
|
|
95
109
|
{ noAck: false }
|
|
96
110
|
);
|
|
97
111
|
}
|
|
@@ -104,12 +118,26 @@ class ServiceRegistryClient extends EventEmitter {
|
|
|
104
118
|
* @private
|
|
105
119
|
*/
|
|
106
120
|
_handleRegistryMessage(msg) {
|
|
121
|
+
// CRITICAL: Handle null message (queue deleted, connection closed, consumer canceled)
|
|
122
|
+
if (!msg) {
|
|
123
|
+
console.warn(`[RegistryClient] ${this.serviceName}: Received null message (queue may be deleted or connection closed)`);
|
|
124
|
+
return; // Don't try to parse or ack null message
|
|
125
|
+
}
|
|
126
|
+
|
|
107
127
|
let payload;
|
|
108
128
|
try {
|
|
109
129
|
payload = JSON.parse(msg.content.toString());
|
|
110
130
|
} catch (err) {
|
|
111
131
|
this.emit('error', err);
|
|
112
|
-
|
|
132
|
+
// Only nack if message is not null
|
|
133
|
+
if (msg) {
|
|
134
|
+
try {
|
|
135
|
+
this.queueManager.channel.nack(msg, false, false);
|
|
136
|
+
} catch (nackErr) {
|
|
137
|
+
console.error(`[RegistryClient] ${this.serviceName}: Failed to nack message:`, nackErr.message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
113
141
|
}
|
|
114
142
|
|
|
115
143
|
// Handle API description request from registry
|
|
@@ -152,8 +180,14 @@ class ServiceRegistryClient extends EventEmitter {
|
|
|
152
180
|
}
|
|
153
181
|
}
|
|
154
182
|
|
|
155
|
-
// Acknowledge all messages
|
|
156
|
-
|
|
183
|
+
// Acknowledge all messages (only if message is not null)
|
|
184
|
+
if (msg) {
|
|
185
|
+
try {
|
|
186
|
+
this.queueManager.channel.ack(msg);
|
|
187
|
+
} catch (ackErr) {
|
|
188
|
+
console.error(`[RegistryClient] ${this.serviceName}: Failed to ack message:`, ackErr.message);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
157
191
|
}
|
|
158
192
|
|
|
159
193
|
/**
|