当前位置:网站首页>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);
}
}
}
边栏推荐
- Alibaba-Canal使用详解(排坑版)_MySQL与ES数据同步
- Recommended areas - ways to explore users' future interests
- TrueType字体文件提取关键信息
- Huawei Hrbrid interface and VLAN division based on IP
- Leetcode 剑指 Offer 59 - II. 队列的最大值
- 国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
- Leetcode 208. Implement trie (prefix tree)
- Electrical data | IEEE118 (including wind and solar energy)
- C web page open WinForm exe
- Docker compose configures MySQL and realizes remote connection
猜你喜欢

基於DVWA的文件上傳漏洞測試

VMware Tools installation error: unable to automatically install vsock driver

Force buckle 9 palindromes

【SSRF-01】服务器端请求伪造漏洞原理及利用实例
![[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry](/img/94/05b2ff62a8a11340cc94c69645db73.png)
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry

dried food! Accelerating sparse neural network through hardware and software co design

3D model format summary

Redis-列表

黄金价格走势k线图如何看?
![[flask] official tutorial -part2: Blueprint - view, template, static file](/img/bd/a736d45d7154119e75428f227af202.png)
[flask] official tutorial -part2: Blueprint - view, template, static file
随机推荐
Code review concerns
Paging of a scratch (page turning processing)
TrueType字体文件提取关键信息
[flask] response, session and message flashing
【Flask】响应、session与Message Flashing
Mongodb problem set
[the most complete in the whole network] |mysql explain full interpretation
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
Development trend of Ali Taobao fine sorting model
[le plus complet du réseau] | interprétation complète de MySQL explicite
ORA-00030
【SSRF-01】服务器端请求伪造漏洞原理及利用实例
Leetcode 208. 实现 Trie (前缀树)
leetcode刷题_反转字符串中的元音字母
False breakthroughs in the trend of London Silver
【已解决】如何生成漂亮的静态文档说明页
竞价推广流程
Alibaba-Canal使用详解(排坑版)_MySQL与ES数据同步
Basic operations of database and table ----- set the fields of the table to be automatically added
【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件