当前位置:网站首页>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);
}
}
}
边栏推荐
- MATLB | real time opportunity constrained decision making and its application in power system
- Superfluid_ HQ hacked analysis
- 037 PHP login, registration, message, personal Center Design
- 竞赛题 2022-6-26
- internship:项目代码所涉及陌生注解及其作用
- A Cooperative Approach to Particle Swarm Optimization
- Unity | 实现面部驱动的两种方式
- 【详细】快速实现对象映射的几种方式
- 【全网最全】 |MySQL EXPLAIN 完全解读
- 晶振是如何起振的?
猜你喜欢

leetcode刷题_验证回文字符串 Ⅱ

2022年PMP项目管理考试敏捷知识点(8)

How does the crystal oscillator vibrate?

Hcip---ipv6 experiment
![[flask] official tutorial -part3: blog blueprint, project installability](/img/fd/fc922b41316338943067469db958e2.png)
[flask] official tutorial -part3: blog blueprint, project installability

TrueType字体文件提取关键信息

Recommended areas - ways to explore users' future interests

500 lines of code to understand the principle of mecached cache client driver

国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!

电气数据|IEEE118(含风能太阳能)
随机推荐
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
Basic operations of database and table ----- delete data table
国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
Unity VR resource flash surface in scene
Leetcode skimming questions_ Verify palindrome string II
【网络攻防实训习题】
Leetcode1961. 检查字符串是否为数组前缀
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
现货白银的一般操作方法
What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
How does the crystal oscillator vibrate?
File upload vulnerability test based on DVWA
NLP第四范式:Prompt概述【Pre-train,Prompt(提示),Predict】【刘鹏飞】
Format code_ What does formatting code mean
SPIR-V初窺
Hcip---ipv6 experiment
Huawei converged VLAN principle and configuration
[flask] response, session and message flashing
How to upgrade kubernetes in place
[network attack and defense training exercises]