I rewrote the MySQL exporter and aim to import Zeebe records into a MySQL database. My logic involves inserting records based on intent first, followed by modifications. However, I encountered efficiency issues with the insertions. I attempted to resolve the issue by using Java 21’s virtual thread pool, but the logs generated are difficult for me to understand.
Using the process instance export as an example, my logs are as follows when the process is not asynchronous
when the process is asynchronous
ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
@Override
public void export(Record<?> record) {
String valueType = record.getValueType().name();
ValueType.JOB.name();
try {
switch (valueType) {
case "PROCESS_INSTANCE":
if (ENABLE_FULL_EXPORT) {
executor.submit(() -> {
try {
exportFullProcessInstanceRecord((Record<ProcessInstanceRecordValue>) record);
exportZcSysLogicProcinst((Record<ProcessInstanceRecordValue>) record);
exportZcSysLogicEleinst((Record<ProcessInstanceRecordValue>) record);
} catch (SQLException e) {
LOGGER.error("Failed to export record", e);
}
});
}
As long as I comment out executor.submit
, the logic works fine. Inside my exportZcSysLogicProcinst
, it’s just an SQL statement execution.