当前位置:网站首页>Flowable source code comments (36) process instance migration status job processor, BPMN history cleanup job processor, external worker task completion job processor
Flowable source code comments (36) process instance migration status job processor, BPMN history cleanup job processor, external worker task completion job processor
2022-07-06 01:35:00 【jinyangjie0】
Flowable Source code address :https://github.com/flowable/flowable-engine
Flowable-6.7.2 Source code comment address :https://github.com/solojin/flowable-6.7.2-annotated
Package path :org.flowable.engine.impl.jobexecutor
ProcessInstanceMigrationStatusJobHandler Process instance migration status job processor
/** * Process instance migration status job processor */
public class ProcessInstanceMigrationStatusJobHandler extends AbstractProcessInstanceMigrationJobHandler {
// type : Process migration status
public static final String TYPE = "process-migration-status";
@Override
public String getType() {
return TYPE;
}
@Override
public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
BatchService batchService = processEngineConfiguration.getBatchServiceConfiguration().getBatchService();
String batchId = getBatchIdFromHandlerCfg(configuration);
Batch batch = batchService.getBatch(batchId);
List<BatchPart> batchParts = batchService.findBatchPartsByBatchId(batchId);
int completedBatchParts = 0;
int failedBatchParts = 0;
for (BatchPart batchPart : batchParts) {
if (batchPart.getCompleteTime() != null) {
completedBatchParts++;
if (ProcessInstanceBatchMigrationResult.RESULT_FAIL.equals(batchPart.getStatus())) {
failedBatchParts++;
}
}
}
if (completedBatchParts == batchParts.size()) {
batchService.completeBatch(batch.getId(), ProcessInstanceBatchMigrationResult.STATUS_COMPLETED);
job.setRepeat(null);
} else {
if (batchParts.size() == 0) {
updateBatchStatus(batch, "No batch parts", batchService);
job.setRepeat(null);
} else {
int completedPercentage = completedBatchParts / batchParts.size() * 100;
updateBatchStatus(batch, completedPercentage + "% completed, " + failedBatchParts + " failed", batchService);
}
}
}
protected void updateBatchStatus(Batch batch, String status, BatchService batchService) {
((BatchEntity) batch).setStatus(ProcessInstanceBatchMigrationResult.STATUS_COMPLETED);
batchService.updateBatch(batch);
}
}
BpmnHistoryCleanupJobHandler BPMN History cleanup job processor
package org.flowable.engine.impl.jobexecutor;
import org.flowable.batch.api.BatchQuery;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.job.service.JobHandler;
import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.flowable.variable.api.delegate.VariableScope;
/** * BPMN History cleanup job processor */
public class BpmnHistoryCleanupJobHandler implements JobHandler {
// type :BPMN History clear
public static final String TYPE = "bpmn-history-cleanup";
private static final String DEFAULT_BATCH_NAME = "Flowable BPMN History Cleanup";
@Override
public String getType() {
return TYPE;
}
@Override
public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
int batchSize = processEngineConfiguration.getCleanInstancesBatchSize();
// Query the history process instance information that can be cleared , And get rid of BPMN history
HistoricProcessInstanceQuery query = processEngineConfiguration.getHistoryCleaningManager().createHistoricProcessInstanceCleaningQuery();
if (processEngineConfiguration.isCleanInstancesSequentially()) {
query.deleteSequentiallyUsingBatch(batchSize, DEFAULT_BATCH_NAME);
} else {
query.deleteInParallelUsingBatch(batchSize, DEFAULT_BATCH_NAME);
}
// Batch query , Query batch erasable information , Clear associated data
BatchQuery batchCleaningQuery = processEngineConfiguration.getHistoryCleaningManager().createBatchCleaningQuery();
if (batchCleaningQuery != null) {
batchCleaningQuery.deleteWithRelatedData();
}
}
}
ExternalWorkerTaskCompleteJobHandler External worker task completion job processor
package org.flowable.engine.impl.jobexecutor;
import java.util.List;
import org.flowable.common.engine.api.scope.ScopeTypes;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.bpmn.helper.ErrorPropagation;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.CountingEntityUtil;
import org.flowable.job.service.JobHandler;
import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.flowable.variable.api.delegate.VariableScope;
import org.flowable.variable.service.VariableService;
import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity;
/** * External worker task completion job processor * * @author Filip Hrisafov */
public class ExternalWorkerTaskCompleteJobHandler implements JobHandler {
// type : External workers complete
public static final String TYPE = "external-worker-complete";
@Override
public String getType() {
return TYPE;
}
@Override
public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
ExecutionEntity executionEntity = (ExecutionEntity) variableScope;
// Mark external worker completion status , And clear the runtime variable information
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
VariableService variableService = processEngineConfiguration.getVariableServiceConfiguration().getVariableService();
List<VariableInstanceEntity> jobVariables = variableService.findVariableInstanceBySubScopeIdAndScopeType(executionEntity.getId(), ScopeTypes.BPMN_EXTERNAL_WORKER);
for (VariableInstanceEntity jobVariable : jobVariables) {
executionEntity.setVariable(jobVariable.getName(), jobVariable.getValue());
CountingEntityUtil.handleDeleteVariableInstanceEntityCount(jobVariable, false);
variableService.deleteVariableInstance(jobVariable);
}
if (configuration != null && configuration.startsWith("error:")) {
String errorCode;
if (configuration.length() > 6) {
errorCode = configuration.substring(6);
} else {
errorCode = null;
}
ErrorPropagation.propagateError(errorCode, executionEntity);
} else {
CommandContextUtil.getAgenda(commandContext).planTriggerExecutionOperation(executionEntity);
}
}
}
边栏推荐
- [the most complete in the whole network] |mysql explain full interpretation
- Leetcode 剑指 Offer 59 - II. 队列的最大值
- Unity | 实现面部驱动的两种方式
- dried food! Accelerating sparse neural network through hardware and software co design
- [技术发展-28]:信息通信网大全、新的技术形态、信息通信行业高质量发展概览
- Code Review关注点
- DOM introduction
- Redis-Key的操作
- Loop structure of program (for loop)
- 【详细】快速实现对象映射的几种方式
猜你喜欢

037 PHP login, registration, message, personal Center Design

3D model format summary

Basic process and testing idea of interface automation

Alibaba-Canal使用详解(排坑版)_MySQL与ES数据同步
Folio.ink 免费、快速、易用的图片分享工具

Unity | two ways to realize facial drive

Threedposetracker project resolution

普通人下场全球贸易,新一轮结构性机会浮出水面

C web page open WinForm exe

General operation method of spot Silver
随机推荐
Docker compose configures MySQL and realizes remote connection
Win10 add file extension
leetcode刷题_平方数之和
Force buckle 1020 Number of enclaves
Folio.ink 免费、快速、易用的图片分享工具
Leetcode 208. 实现 Trie (前缀树)
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
leetcode刷题_反转字符串中的元音字母
[flask] static file and template rendering
剑指 Offer 12. 矩阵中的路径
Internship: unfamiliar annotations involved in the project code and their functions
VMware Tools installation error: unable to automatically install vsock driver
SCM Chinese data distribution
Basic operations of databases and tables ----- unique constraints
ctf. Show PHP feature (89~110)
国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
Huawei converged VLAN principle and configuration
Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem
Ordinary people end up in Global trade, and a new round of structural opportunities emerge
Cookie concept, basic use, principle, details and Chinese transmission