@onlineapps/mq-client-core 1.0.46 → 1.0.48
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/mq-client-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"amqplib": "^0.10.3",
|
|
24
24
|
"ajv": "^8.12.0",
|
|
25
|
-
"lodash.merge": "^4.6.2"
|
|
25
|
+
"lodash.merge": "^4.6.2",
|
|
26
|
+
"@onlineapps/infrastructure-tools": "^1.0.23"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"jest": "^29.7.0"
|
|
@@ -336,6 +336,7 @@ module.exports = {
|
|
|
336
336
|
queueName.startsWith('infrastructure.') ||
|
|
337
337
|
queueName.startsWith('validation.') ||
|
|
338
338
|
queueName.startsWith('monitoring.') ||
|
|
339
|
+
queueName.startsWith('telemetry.') ||
|
|
339
340
|
queueName.startsWith('delivery.');
|
|
340
341
|
},
|
|
341
342
|
|
|
@@ -436,7 +437,7 @@ module.exports = {
|
|
|
436
437
|
|
|
437
438
|
/**
|
|
438
439
|
* Get monitoring queue configuration
|
|
439
|
-
* @param {string} queueName - Queue name (e.g., 'monitoring.workflow
|
|
440
|
+
* @param {string} queueName - Queue name (e.g., 'monitoring.workflow')
|
|
440
441
|
* @returns {Object} Queue configuration
|
|
441
442
|
*/
|
|
442
443
|
getMonitoringQueueConfig(queueName) {
|
|
@@ -449,7 +450,7 @@ module.exports = {
|
|
|
449
450
|
|
|
450
451
|
/**
|
|
451
452
|
* Get infrastructure queue configuration by queue name (auto-detect type)
|
|
452
|
-
* @param {string} queueName - Full queue name (e.g., 'workflow.init', 'registry.register', 'infrastructure.health.checks', 'monitoring.workflow
|
|
453
|
+
* @param {string} queueName - Full queue name (e.g., 'workflow.init', 'registry.register', 'infrastructure.health.checks', 'monitoring.workflow')
|
|
453
454
|
* @returns {Object} Queue configuration
|
|
454
455
|
*/
|
|
455
456
|
getInfrastructureQueueConfig(queueName) {
|
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
const PublishLayer = require('../layers/PublishLayer');
|
|
18
18
|
const RecoveryWorker = require('../workers/RecoveryWorker');
|
|
19
19
|
const PublishMonitor = require('../monitoring/PublishMonitor');
|
|
20
|
+
const { createInfraLogger } = require('@onlineapps/infrastructure-tools');
|
|
20
21
|
|
|
21
22
|
class RabbitMQClient extends EventEmitter {
|
|
22
23
|
/**
|
|
@@ -101,6 +102,9 @@ class RabbitMQClient extends EventEmitter {
|
|
|
101
102
|
this._criticalHealthShutdownDelay = this._config.criticalHealthShutdownDelay || 60000; // Default: 60s delay before shutdown
|
|
102
103
|
this._criticalHealthStartTime = null; // Track when critical health started
|
|
103
104
|
|
|
105
|
+
// Create structured logger for infrastructure logging
|
|
106
|
+
this._log = createInfraLogger('mq-client-core', 'transport');
|
|
107
|
+
|
|
104
108
|
// Publish layer (retry + buffer)
|
|
105
109
|
this._publishLayer = new PublishLayer({
|
|
106
110
|
client: this,
|
|
@@ -1067,13 +1071,26 @@ class RabbitMQClient extends EventEmitter {
|
|
|
1067
1071
|
// Track operation for debugging
|
|
1068
1072
|
this._trackChannelOperation(this._channel, `publish to ${queue}`);
|
|
1069
1073
|
|
|
1070
|
-
// Log publish attempt for debugging
|
|
1071
|
-
console.log(`[RabbitMQClient] [mq-client-core] [PUBLISH] Attempting to publish to queue "${queue}"`);
|
|
1072
|
-
|
|
1073
1074
|
const exchange = this._config.exchange || '';
|
|
1074
1075
|
const routingKey = options.routingKey || queue;
|
|
1075
1076
|
const persistent = options.persistent !== undefined ? options.persistent : this._config.durable;
|
|
1076
1077
|
const headers = options.headers || {};
|
|
1078
|
+
|
|
1079
|
+
// Structured log: extract workflow_id from headers for traceability
|
|
1080
|
+
const workflowId = headers.workflowId || headers.workflow_id || 'unknown';
|
|
1081
|
+
const msgSize = buffer ? buffer.length : 0;
|
|
1082
|
+
this._log.input(workflowId, 'PUBLISH_START', {
|
|
1083
|
+
handler: 'publish',
|
|
1084
|
+
function: 'RabbitMQClient._publishOnce',
|
|
1085
|
+
input: {
|
|
1086
|
+
queue,
|
|
1087
|
+
size: msgSize,
|
|
1088
|
+
exchange: exchange || '(default)',
|
|
1089
|
+
routing_key: routingKey,
|
|
1090
|
+
persistent
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1077
1094
|
|
|
1078
1095
|
try {
|
|
1079
1096
|
// Ensure queue exists if publishing directly to queue and using default exchange
|
|
@@ -1221,7 +1238,14 @@ class RabbitMQClient extends EventEmitter {
|
|
|
1221
1238
|
reject(err);
|
|
1222
1239
|
}
|
|
1223
1240
|
} else {
|
|
1224
|
-
|
|
1241
|
+
// Structured log: publish confirmed
|
|
1242
|
+
const wfId = headers.workflowId || headers.workflow_id || 'unknown';
|
|
1243
|
+
this._log.output(wfId, 'PUBLISH_CONFIRMED', {
|
|
1244
|
+
handler: 'publish',
|
|
1245
|
+
function: 'RabbitMQClient._publishOnce',
|
|
1246
|
+
input: { queue, size: buffer ? buffer.length : 0 },
|
|
1247
|
+
output: { status: 'confirmed', queue }
|
|
1248
|
+
});
|
|
1225
1249
|
resolve();
|
|
1226
1250
|
}
|
|
1227
1251
|
});
|
|
@@ -1453,6 +1477,20 @@ class RabbitMQClient extends EventEmitter {
|
|
|
1453
1477
|
return; // Consumer cancellation
|
|
1454
1478
|
}
|
|
1455
1479
|
|
|
1480
|
+
// Structured log: message received
|
|
1481
|
+
const msgHeaders = msg.properties?.headers || {};
|
|
1482
|
+
const wfId = msgHeaders.workflowId || msgHeaders.workflow_id || 'unknown';
|
|
1483
|
+
const msgSize = msg.content ? msg.content.length : 0;
|
|
1484
|
+
this._log.input(wfId, 'MSG_RECEIVED', {
|
|
1485
|
+
handler: 'consume',
|
|
1486
|
+
function: 'RabbitMQClient.consume',
|
|
1487
|
+
input: {
|
|
1488
|
+
queue,
|
|
1489
|
+
size: msgSize,
|
|
1490
|
+
consumer_tag: msg.fields?.consumerTag || null
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1456
1494
|
// Track in-flight message (increment)
|
|
1457
1495
|
const tracking = this._prefetchTracking.get(queue);
|
|
1458
1496
|
if (tracking) {
|
|
@@ -1466,6 +1504,14 @@ class RabbitMQClient extends EventEmitter {
|
|
|
1466
1504
|
// Acknowledge message after successful processing
|
|
1467
1505
|
if (!noAck) {
|
|
1468
1506
|
this._consumerChannel.ack(msg);
|
|
1507
|
+
// Structured log: message acknowledged
|
|
1508
|
+
this._log.output(wfId, 'MSG_ACKED', {
|
|
1509
|
+
handler: 'consume',
|
|
1510
|
+
function: 'RabbitMQClient.consume',
|
|
1511
|
+
input: { queue },
|
|
1512
|
+
output: { status: 'acknowledged', queue }
|
|
1513
|
+
});
|
|
1514
|
+
|
|
1469
1515
|
// Track ack (decrement in-flight)
|
|
1470
1516
|
if (tracking) {
|
|
1471
1517
|
tracking.inFlight = Math.max(0, tracking.inFlight - 1);
|