fix - 调整 ES 同步功能

This commit is contained in:
wangli 2024-11-06 09:24:43 +08:00
parent 271e5b2b34
commit 0837505242
2 changed files with 7 additions and 17 deletions

View File

@ -50,11 +50,11 @@ public class CustomElasticSearchAsyncCmd extends AbstractCommand<Void> implement
String jobId = startAsync(processEngineConfiguration, instance);
// 重置任务因为上面的 cmd 和这个 cmd lock 对象不一致
JobServiceConfiguration jobServiceConfiguration = processEngineConfiguration.getJobServiceConfiguration();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
CommandConfig commandConfig = new CommandConfig().transactionRequired();
commandExecutor.execute(commandConfig, new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
// // 重置任务因为上面的 cmd 和这个 cmd lock 对象不一致
// JobServiceConfiguration jobServiceConfiguration = processEngineConfiguration.getJobServiceConfiguration();
// CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
// CommandConfig commandConfig = new CommandConfig().transactionRequired();
// commandExecutor.execute(commandConfig, new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
return null;
}

View File

@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.impl.cfg.TransactionListener;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.springframework.scheduling.annotation.Async;
/**
* 引擎内的动作事务提交后执行同步 ES
@ -21,21 +22,10 @@ public class OnTxCommittedSyncToEsListener implements TransactionListener {
private final String uuid;
@Override
@Async
public void execute(CommandContext commandContext) {
log.info("SyncEsTaskEntityEventHandle onInitialized uuid:{}, processInstanceId:{}, taskId: {}", uuid, processInstanceId, taskId);
// ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
// HistoryService historyService = processEngineConfiguration.getHistoryService();
// HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
// .processInstanceId(processInstanceId)
// .singleResult();
// // 删除指定实例的父子文档
// log.info("delete document processInstanceId: {}", processInstanceId);
// aggregateProcessInstanceService.deleteDocumentParentAndChild(processInstanceId);
// log.info("reInsert document processInstanceId: {}", processInstanceId);
// List<ProcessTaskDocument> processTaskDocuments = aggregateProcessInstanceService.syncProcessInstance(historicProcessInstance, null);
// log.info("Insert Summary: ProcessInstance Count: {}, ProcessTask Count: {}", 1, processTaskDocuments.size());
CommandContextUtil.getProcessEngineConfiguration(commandContext).getCommandExecutor()
.execute(new CustomElasticSearchAsyncCmd(processInstanceId));
}