wsp-ms-core 1.1.26 → 1.1.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/dist/index.cjs +92 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +92 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -719,7 +719,7 @@ declare class DefaultMysqlInboxRunner {
|
|
|
719
719
|
start(): Promise<void>;
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
type InboxHandlerProcessor = (record: InboxRecord) => void
|
|
722
|
+
type InboxHandlerProcessor = (record: InboxRecord) => Promise<void>;
|
|
723
723
|
type InboxErrorHandler = (record: InboxRecord, error: any) => void;
|
|
724
724
|
declare class DefaultMysqlInboxProcessor {
|
|
725
725
|
private uovFactory;
|
package/dist/index.d.ts
CHANGED
|
@@ -719,7 +719,7 @@ declare class DefaultMysqlInboxRunner {
|
|
|
719
719
|
start(): Promise<void>;
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
type InboxHandlerProcessor = (record: InboxRecord) => void
|
|
722
|
+
type InboxHandlerProcessor = (record: InboxRecord) => Promise<void>;
|
|
723
723
|
type InboxErrorHandler = (record: InboxRecord, error: any) => void;
|
|
724
724
|
declare class DefaultMysqlInboxProcessor {
|
|
725
725
|
private uovFactory;
|
package/dist/index.js
CHANGED
|
@@ -1187,9 +1187,9 @@ var _EventBus = class _EventBus {
|
|
|
1187
1187
|
await this.repository.create(mapper(event));
|
|
1188
1188
|
}
|
|
1189
1189
|
async publishMany(events) {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1190
|
+
await Promise.all(
|
|
1191
|
+
events.map((event) => this.publish(event))
|
|
1192
|
+
);
|
|
1193
1193
|
}
|
|
1194
1194
|
static addMapper(eventType, mapper) {
|
|
1195
1195
|
_EventBus.MAPPERS.set(eventType, mapper);
|
|
@@ -1244,8 +1244,30 @@ var EventManager = class {
|
|
|
1244
1244
|
this._onReconnect = null;
|
|
1245
1245
|
}
|
|
1246
1246
|
async execRoute(topic, event) {
|
|
1247
|
-
|
|
1248
|
-
|
|
1247
|
+
console.log("[KafkaManager] execRoute START", {
|
|
1248
|
+
topic
|
|
1249
|
+
});
|
|
1250
|
+
const callback = this._callbackList[topic];
|
|
1251
|
+
if (!callback) {
|
|
1252
|
+
console.log("[KafkaManager] execRoute NO CALLBACK", {
|
|
1253
|
+
topic
|
|
1254
|
+
});
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
const start = Date.now();
|
|
1258
|
+
try {
|
|
1259
|
+
await callback(event);
|
|
1260
|
+
console.log("[KafkaManager] execRoute END", {
|
|
1261
|
+
topic,
|
|
1262
|
+
elapsedMs: Date.now() - start
|
|
1263
|
+
});
|
|
1264
|
+
} catch (e) {
|
|
1265
|
+
console.error("[KafkaManager] execRoute ERROR", {
|
|
1266
|
+
topic,
|
|
1267
|
+
elapsedMs: Date.now() - start,
|
|
1268
|
+
error: e
|
|
1269
|
+
});
|
|
1270
|
+
throw e;
|
|
1249
1271
|
}
|
|
1250
1272
|
}
|
|
1251
1273
|
async execCallback(callback, data) {
|
|
@@ -1945,31 +1967,70 @@ var KafkaManager = class extends EventManager {
|
|
|
1945
1967
|
autoCommit: false,
|
|
1946
1968
|
// @ts-ignore
|
|
1947
1969
|
eachMessage: async ({ topic, partition, message, heartbeat }) => {
|
|
1970
|
+
console.log("[KafkaManager] A - eachMessage START", {
|
|
1971
|
+
topic,
|
|
1972
|
+
partition,
|
|
1973
|
+
offset: message.offset
|
|
1974
|
+
});
|
|
1948
1975
|
try {
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
message: json.data
|
|
1961
|
-
};
|
|
1962
|
-
} catch (error) {
|
|
1963
|
-
await this.commitMessage(topic, partition, message);
|
|
1964
|
-
await heartbeat();
|
|
1965
|
-
throw error;
|
|
1976
|
+
console.log("[KafkaManager] B - before execCallback(_onMessage)");
|
|
1977
|
+
await this.execCallback(
|
|
1978
|
+
this._onMessage,
|
|
1979
|
+
`[New message detected for ${topic}]: ${message.value?.toString()}`
|
|
1980
|
+
);
|
|
1981
|
+
console.log("[KafkaManager] C - after execCallback(_onMessage)");
|
|
1982
|
+
console.log("[KafkaManager] D - before JSON.parse");
|
|
1983
|
+
const json = JSON.parse(message.value.toString());
|
|
1984
|
+
console.log("[KafkaManager] E - after JSON.parse");
|
|
1985
|
+
if (!json.data) {
|
|
1986
|
+
json.data = {};
|
|
1966
1987
|
}
|
|
1988
|
+
console.log("[KafkaManager] F - before EventMessage creation");
|
|
1989
|
+
const event = {
|
|
1990
|
+
topic: String(topic),
|
|
1991
|
+
producer: String(json.producer),
|
|
1992
|
+
tenant: UUID.create(String(json.tenant)),
|
|
1993
|
+
message: json.data
|
|
1994
|
+
};
|
|
1995
|
+
console.log("[KafkaManager] G - EventMessage created");
|
|
1996
|
+
const execRouteStart = Date.now();
|
|
1997
|
+
console.log("[KafkaManager] H - before execRoute", {
|
|
1998
|
+
offset: message.offset
|
|
1999
|
+
});
|
|
1967
2000
|
await this.execRoute(topic, event);
|
|
2001
|
+
console.log("[KafkaManager] I - after execRoute", {
|
|
2002
|
+
elapsedMs: Date.now() - execRouteStart
|
|
2003
|
+
});
|
|
2004
|
+
const commitStart = Date.now();
|
|
2005
|
+
console.log("[KafkaManager] J - before commitMessage");
|
|
1968
2006
|
await this.commitMessage(topic, partition, message);
|
|
2007
|
+
console.log("[KafkaManager] K - after commitMessage", {
|
|
2008
|
+
elapsedMs: Date.now() - commitStart
|
|
2009
|
+
});
|
|
2010
|
+
const hbStart = Date.now();
|
|
2011
|
+
console.log("[KafkaManager] L - before heartbeat");
|
|
1969
2012
|
await heartbeat();
|
|
2013
|
+
console.log("[KafkaManager] M - after heartbeat", {
|
|
2014
|
+
elapsedMs: Date.now() - hbStart
|
|
2015
|
+
});
|
|
2016
|
+
console.log("[KafkaManager] N - eachMessage END");
|
|
1970
2017
|
} catch (error) {
|
|
1971
|
-
|
|
1972
|
-
|
|
2018
|
+
console.error("[KafkaManager] ERROR inside eachMessage", {
|
|
2019
|
+
topic,
|
|
2020
|
+
partition,
|
|
2021
|
+
offset: message.offset,
|
|
2022
|
+
error
|
|
2023
|
+
});
|
|
2024
|
+
try {
|
|
2025
|
+
await this.execCallback(this._onError, error);
|
|
2026
|
+
} catch (callbackError) {
|
|
2027
|
+
console.error("[KafkaManager] ERROR executing _onError callback", callbackError);
|
|
2028
|
+
}
|
|
2029
|
+
this.handleKafkaError(error, "consumer.eachMessage", {
|
|
2030
|
+
topic,
|
|
2031
|
+
partition,
|
|
2032
|
+
offset: message.offset
|
|
2033
|
+
});
|
|
1973
2034
|
throw error;
|
|
1974
2035
|
}
|
|
1975
2036
|
}
|
|
@@ -2260,7 +2321,13 @@ var DefaultMysqlInboxRunner = class {
|
|
|
2260
2321
|
for (let topic of this.topics) {
|
|
2261
2322
|
try {
|
|
2262
2323
|
this.eventManager.route(topic, async (e) => {
|
|
2263
|
-
|
|
2324
|
+
console.log("[InboxRunner] BEFORE getConnection");
|
|
2325
|
+
const connection = await this.databaseConnector.getConnection();
|
|
2326
|
+
console.log("[InboxRunner] AFTER getConnection");
|
|
2327
|
+
const repository = new InboxMysqlRepository(connection);
|
|
2328
|
+
console.log("[InboxRunner] BEFORE saveEvent");
|
|
2329
|
+
await this.saveEvent(e, repository);
|
|
2330
|
+
console.log("[InboxRunner] AFTER saveEvent");
|
|
2264
2331
|
});
|
|
2265
2332
|
} catch (error) {
|
|
2266
2333
|
console.log(error.toString());
|