wsp-ms-core 1.1.30 → 1.1.32
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/dist/index.cjs +12 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2009,58 +2009,32 @@ var KafkaManager = class extends EventManager {
|
|
|
2009
2009
|
autoCommit: false,
|
|
2010
2010
|
// @ts-ignore
|
|
2011
2011
|
eachMessage: async ({ topic, partition, message, heartbeat }) => {
|
|
2012
|
-
console.log("[KafkaManager] A - eachMessage START", {
|
|
2013
|
-
topic,
|
|
2014
|
-
partition,
|
|
2015
|
-
offset: message.offset
|
|
2016
|
-
});
|
|
2017
2012
|
try {
|
|
2018
|
-
console.log("[KafkaManager] B - before execCallback(_onMessage)");
|
|
2019
2013
|
await this.execCallback(
|
|
2020
2014
|
this._onMessage,
|
|
2021
2015
|
`[New message detected for ${topic}]: ${message.value?.toString()}`
|
|
2022
2016
|
);
|
|
2023
|
-
console.log("[KafkaManager] C - after execCallback(_onMessage)");
|
|
2024
|
-
console.log("[KafkaManager] D - before JSON.parse");
|
|
2025
2017
|
const json = JSON.parse(message.value.toString());
|
|
2026
|
-
console.log("[KafkaManager] E - after JSON.parse");
|
|
2027
2018
|
if (!json.data) {
|
|
2028
2019
|
json.data = {};
|
|
2029
2020
|
}
|
|
2030
|
-
console.log("[KafkaManager] F - before EventMessage creation");
|
|
2031
2021
|
const event = {
|
|
2032
2022
|
topic: String(topic),
|
|
2033
2023
|
producer: String(json.producer),
|
|
2034
2024
|
tenant: UUID.create(String(json.tenant)),
|
|
2035
2025
|
message: json.data
|
|
2036
2026
|
};
|
|
2037
|
-
console.log("[KafkaManager] G - EventMessage created");
|
|
2038
2027
|
const execRouteStart = Date.now();
|
|
2039
|
-
console.log("[KafkaManager] H - before execRoute", {
|
|
2040
|
-
offset: message.offset
|
|
2041
|
-
});
|
|
2042
2028
|
const stopHeartbeatLoop = this.startHeartbeatLoop(heartbeat);
|
|
2043
2029
|
try {
|
|
2044
2030
|
await this.execRoute(topic, event);
|
|
2045
2031
|
} finally {
|
|
2046
2032
|
stopHeartbeatLoop();
|
|
2047
2033
|
}
|
|
2048
|
-
console.log("[KafkaManager] I - after execRoute", {
|
|
2049
|
-
elapsedMs: Date.now() - execRouteStart
|
|
2050
|
-
});
|
|
2051
2034
|
const commitStart = Date.now();
|
|
2052
|
-
console.log("[KafkaManager] J - before commitMessage");
|
|
2053
2035
|
await this.commitMessage(topic, partition, message);
|
|
2054
|
-
console.log("[KafkaManager] K - after commitMessage", {
|
|
2055
|
-
elapsedMs: Date.now() - commitStart
|
|
2056
|
-
});
|
|
2057
2036
|
const hbStart = Date.now();
|
|
2058
|
-
console.log("[KafkaManager] L - before heartbeat");
|
|
2059
2037
|
await heartbeat();
|
|
2060
|
-
console.log("[KafkaManager] M - after heartbeat", {
|
|
2061
|
-
elapsedMs: Date.now() - hbStart
|
|
2062
|
-
});
|
|
2063
|
-
console.log("[KafkaManager] N - eachMessage END");
|
|
2064
2038
|
} catch (error) {
|
|
2065
2039
|
console.error("[KafkaManager] ERROR inside eachMessage", {
|
|
2066
2040
|
topic,
|
|
@@ -2161,9 +2135,12 @@ var _MysqlConnector = class _MysqlConnector {
|
|
|
2161
2135
|
return rows;
|
|
2162
2136
|
}
|
|
2163
2137
|
async getConnection() {
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2138
|
+
const conn = await Promise.race([
|
|
2139
|
+
this._pool.getConnection(),
|
|
2140
|
+
new Promise(
|
|
2141
|
+
(_, reject) => setTimeout(() => reject(new Error("pool.getConnection timeout")), 1e4)
|
|
2142
|
+
)
|
|
2143
|
+
]);
|
|
2167
2144
|
return this.wrap(conn);
|
|
2168
2145
|
}
|
|
2169
2146
|
async closePool() {
|
|
@@ -2374,13 +2351,13 @@ var DefaultMysqlInboxRunner = class {
|
|
|
2374
2351
|
for (let topic of this.topics) {
|
|
2375
2352
|
try {
|
|
2376
2353
|
this.eventManager.route(topic, async (e) => {
|
|
2377
|
-
console.log("[InboxRunner] BEFORE getConnection");
|
|
2378
2354
|
const connection = await this.databaseConnector.getConnection();
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2355
|
+
try {
|
|
2356
|
+
const repository = new InboxMysqlRepository(connection);
|
|
2357
|
+
await this.saveEvent(e, repository);
|
|
2358
|
+
} finally {
|
|
2359
|
+
await connection.close();
|
|
2360
|
+
}
|
|
2384
2361
|
});
|
|
2385
2362
|
} catch (error) {
|
|
2386
2363
|
console.log(error.toString());
|