@onlineapps/service-wrapper 2.0.26 → 2.0.28
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 +2 -2
- package/src/ServiceWrapper.js +31 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/service-wrapper",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.28",
|
|
4
4
|
"description": "Thin orchestration layer for microservices - delegates all infrastructure concerns to specialized connectors",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@onlineapps/conn-base-cache": "^1.0.0",
|
|
28
28
|
"@onlineapps/conn-base-monitoring": "^1.0.1",
|
|
29
29
|
"@onlineapps/conn-infra-error-handler": "^1.0.0",
|
|
30
|
-
"@onlineapps/conn-infra-mq": "^1.1.
|
|
30
|
+
"@onlineapps/conn-infra-mq": "^1.1.8",
|
|
31
31
|
"@onlineapps/conn-orch-api-mapper": "^1.0.0",
|
|
32
32
|
"@onlineapps/conn-orch-cookbook": "^2.0.0",
|
|
33
33
|
"@onlineapps/conn-orch-orchestrator": "^1.0.1",
|
package/src/ServiceWrapper.js
CHANGED
|
@@ -151,13 +151,10 @@ class ServiceWrapper {
|
|
|
151
151
|
await this._initializeMonitoring();
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// 2. Initialize MQ connection
|
|
154
|
+
// 2. Initialize MQ connection
|
|
155
155
|
if (this.config.wrapper?.mq?.enabled !== false) {
|
|
156
156
|
await this._initializeMQ();
|
|
157
|
-
|
|
158
|
-
// Start workflow.init listener immediately (independent of service registration)
|
|
159
|
-
// This allows the system to receive workflow messages even if service validation/registration fails
|
|
160
|
-
await this._startWorkflowInitListener();
|
|
157
|
+
// NOTE: workflow.init listener starts ONLY after successful registration (see _initializeRegistry)
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
// 3. Run pre-validation (Tier 1)
|
|
@@ -261,6 +258,25 @@ class ServiceWrapper {
|
|
|
261
258
|
|
|
262
259
|
await this.mqClient.connect();
|
|
263
260
|
console.log('MQ connector initialized');
|
|
261
|
+
|
|
262
|
+
// Initialize infrastructure queues using unified tool
|
|
263
|
+
// All services (infrastructure AND business) should create infrastructure queues
|
|
264
|
+
// This ensures consistent parameters across all services
|
|
265
|
+
if (this.config.wrapper?.mq?.initInfrastructureQueues !== false) {
|
|
266
|
+
try {
|
|
267
|
+
const { initInfrastructureQueues } = require('@onlineapps/conn-infra-mq').utils || {};
|
|
268
|
+
if (initInfrastructureQueues && this.mqClient._transport?.channel) {
|
|
269
|
+
await initInfrastructureQueues(this.mqClient._transport.channel, {
|
|
270
|
+
logger: this.logger || console
|
|
271
|
+
});
|
|
272
|
+
console.log('✓ Infrastructure queues initialized');
|
|
273
|
+
}
|
|
274
|
+
} catch (error) {
|
|
275
|
+
// If tool not available or fails, log warning but continue
|
|
276
|
+
// Infrastructure queues may have been created by other services
|
|
277
|
+
console.warn('⚠ Could not initialize infrastructure queues:', error.message);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
264
280
|
}
|
|
265
281
|
|
|
266
282
|
/**
|
|
@@ -315,13 +331,16 @@ class ServiceWrapper {
|
|
|
315
331
|
console.log(`✓ Certificate received: ${registrationResult.certificate.certificateId}`);
|
|
316
332
|
}
|
|
317
333
|
|
|
318
|
-
// CRITICAL:
|
|
319
|
-
// workflow.init
|
|
334
|
+
// CRITICAL: Start workflow listeners ONLY after successful validation and registration with certificate
|
|
335
|
+
// Both workflow.init and service-specific listeners start here
|
|
320
336
|
if (registrationResult.success && registrationResult.certificate) {
|
|
321
|
-
console.log('✓ Certificate validated, starting
|
|
337
|
+
console.log('✓ Certificate validated, starting workflow listeners...');
|
|
338
|
+
// Start workflow.init listener (for all services)
|
|
339
|
+
await this._startWorkflowInitListener();
|
|
340
|
+
// Start service-specific workflow listener
|
|
322
341
|
await this._startServiceWorkflowListener();
|
|
323
342
|
} else {
|
|
324
|
-
console.warn('⚠ Registration succeeded but no certificate received -
|
|
343
|
+
console.warn('⚠ Registration succeeded but no certificate received - workflow listeners NOT started');
|
|
325
344
|
}
|
|
326
345
|
|
|
327
346
|
} catch (error) {
|
|
@@ -455,8 +474,8 @@ class ServiceWrapper {
|
|
|
455
474
|
}
|
|
456
475
|
|
|
457
476
|
/**
|
|
458
|
-
* Start workflow.init listener (runs
|
|
459
|
-
*
|
|
477
|
+
* Start workflow.init listener (runs ONLY after successful registration)
|
|
478
|
+
* Service must be registered and have a certificate before listening to workflow.init
|
|
460
479
|
* @private
|
|
461
480
|
*/
|
|
462
481
|
async _startWorkflowInitListener() {
|
|
@@ -470,7 +489,7 @@ class ServiceWrapper {
|
|
|
470
489
|
await this._processWorkflowMessage(message, 'workflow.init');
|
|
471
490
|
});
|
|
472
491
|
|
|
473
|
-
console.log('✓ workflow.init listener started (
|
|
492
|
+
console.log('✓ workflow.init listener started (after successful registration)');
|
|
474
493
|
}
|
|
475
494
|
|
|
476
495
|
/**
|