反序列化问题。
This commit is contained in:
parent
9c582f7e5b
commit
e59b14c90c
@ -21,7 +21,7 @@ public class FlowableEventDispatcher implements FlowableEventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onEvent(FlowableEvent event) {
|
public void onEvent(FlowableEvent event) {
|
||||||
String eventType = event.getType().name();
|
String eventType = event.getType().name();
|
||||||
log.info("Dispatching Flowable event: {}, event class: {}", eventType, event.getClass().getName());
|
// log.info("Dispatching Flowable event: {}, event class: {}", eventType, event.getClass().getName());
|
||||||
|
|
||||||
for (IFlowableEventHandler handler : eventHandlers) {
|
for (IFlowableEventHandler handler : eventHandlers) {
|
||||||
if (handler.canHandle(eventType)) {
|
if (handler.canHandle(eventType)) {
|
||||||
|
|||||||
@ -33,24 +33,24 @@ public class ProcessEventHandler implements IFlowableEventHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(FlowableEvent event) {
|
public void handle(FlowableEvent event) {
|
||||||
String eventType = event.getType().name();
|
String eventType = event.getType().name();
|
||||||
// log.info("Processing event: {}", eventType);
|
log.info("Processing event: {}", eventType);
|
||||||
|
|
||||||
FlowableProcessEngineEvent processEvent = (FlowableProcessEngineEvent) event;
|
FlowableProcessEngineEvent processEvent = (FlowableProcessEngineEvent) event;
|
||||||
WorkflowInstanceStatusEnums status = convertToWorkflowStatus(eventType);
|
WorkflowInstanceStatusEnums status = convertToWorkflowStatus(eventType);
|
||||||
|
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
// HistoricProcessInstance historicProcessInstance = processEngine.getHistoryService()
|
HistoricProcessInstance historicProcessInstance = processEngine.getHistoryService()
|
||||||
// .createHistoricProcessInstanceQuery()
|
.createHistoricProcessInstanceQuery()
|
||||||
// .processInstanceId(processEvent.getProcessInstanceId())
|
.processInstanceId(processEvent.getProcessInstanceId())
|
||||||
// .singleResult();
|
.singleResult();
|
||||||
//
|
|
||||||
// publisher.publishEvent(WorkflowInstanceStatusChangeEvent.builder()
|
publisher.publishEvent(WorkflowInstanceStatusChangeEvent.builder()
|
||||||
// .processInstanceId(processEvent.getProcessInstanceId())
|
.processInstanceId(processEvent.getProcessInstanceId())
|
||||||
// .status(status)
|
.status(status)
|
||||||
// .endTime(historicProcessInstance != null && historicProcessInstance.getEndTime() != null ?
|
.endTime(historicProcessInstance != null && historicProcessInstance.getEndTime() != null ?
|
||||||
// DateUtil.toLocalDateTime(historicProcessInstance.getEndTime()) : null)
|
DateUtil.toLocalDateTime(historicProcessInstance.getEndTime()) : null)
|
||||||
// .build()
|
.build()
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +63,7 @@ public class ProcessEventHandler implements IFlowableEventHandler {
|
|||||||
case "PROCESS_CANCELLED" -> WorkflowInstanceStatusEnums.TERMINATED;
|
case "PROCESS_CANCELLED" -> WorkflowInstanceStatusEnums.TERMINATED;
|
||||||
case "PROCESS_SUSPENDED" -> WorkflowInstanceStatusEnums.SUSPENDED;
|
case "PROCESS_SUSPENDED" -> WorkflowInstanceStatusEnums.SUSPENDED;
|
||||||
case "PROCESS_RESUMED" -> WorkflowInstanceStatusEnums.RUNNING;
|
case "PROCESS_RESUMED" -> WorkflowInstanceStatusEnums.RUNNING;
|
||||||
|
case "PROCESS_COMPLETED_WITH_TERMINATE_END_EVENT" -> WorkflowInstanceStatusEnums.TERMINATED;
|
||||||
default -> null;
|
default -> null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,38 +149,83 @@ public class BpmnConverter {
|
|||||||
serviceTask.setExtensionElements(extensionElements);
|
serviceTask.setExtensionElements(extensionElements);
|
||||||
|
|
||||||
// 添加错误边界事件
|
// 添加错误边界事件
|
||||||
BoundaryEvent boundaryEvent = new BoundaryEvent();
|
addErrorBoundaryEventHandler(process, serviceTask);
|
||||||
boundaryEvent.setId(WorkFlowConstants.BOUNDARY_EVENT_ERROR_PREFIX + serviceTask.getId());
|
|
||||||
// boundaryEvent.setName("错误边界事件");
|
|
||||||
boundaryEvent.setAttachedToRef(serviceTask);
|
|
||||||
boundaryEvent.setAttachedToRefId(serviceTask.getId());
|
|
||||||
boundaryEvent.setCancelActivity(true); // 确保取消原有活动
|
|
||||||
|
|
||||||
// 配置错误事件定义
|
|
||||||
ErrorEventDefinition errorEventDefinition = new ErrorEventDefinition();
|
|
||||||
errorEventDefinition.setErrorCode(WorkFlowConstants.WORKFLOW_EXEC_ERROR);
|
|
||||||
boundaryEvent.addEventDefinition(errorEventDefinition);
|
|
||||||
|
|
||||||
// 添加错误结束事件
|
|
||||||
EndEvent errorEndEvent = new EndEvent();
|
|
||||||
errorEndEvent.setId(WorkFlowConstants.END_EVENT_ERROR_PREFIX + serviceTask.getId());
|
|
||||||
// errorEndEvent.setName("错误结束事件");
|
|
||||||
|
|
||||||
// 添加终止定义
|
|
||||||
TerminateEventDefinition terminateEventDefinition = new TerminateEventDefinition();
|
|
||||||
errorEndEvent.addEventDefinition(terminateEventDefinition);
|
|
||||||
|
|
||||||
// 添加从边界事件到结束事件的连线
|
|
||||||
SequenceFlow errorFlow = new SequenceFlow();
|
|
||||||
errorFlow.setId(WorkFlowConstants.SEQUENCE_FLOW_ERROR_PREFIX + serviceTask.getId());
|
|
||||||
// errorFlow.setName("错误处理流程");
|
|
||||||
errorFlow.setSourceRef(boundaryEvent.getId());
|
|
||||||
errorFlow.setTargetRef(errorEndEvent.getId());
|
|
||||||
|
|
||||||
// 将错误处理相关的元素添加到流程中
|
|
||||||
process.addFlowElement(boundaryEvent);
|
|
||||||
process.addFlowElement(errorEndEvent);
|
|
||||||
process.addFlowElement(errorFlow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为服务任务添加错误边界事件和错误结束事件
|
||||||
|
* 当服务任务执行失败时,会触发错误边界事件,并流转到错误结束事件
|
||||||
|
*
|
||||||
|
* @param process BPMN流程定义
|
||||||
|
* @param serviceTask 需要添加错误处理的服务任务
|
||||||
|
*/
|
||||||
|
private void addErrorBoundaryEventHandler(Process process, ServiceTask serviceTask) {
|
||||||
|
BoundaryEvent boundaryEvent = createErrorBoundaryEvent(serviceTask);
|
||||||
|
EndEvent errorEndEvent = createErrorEndEvent(serviceTask);
|
||||||
|
SequenceFlow errorFlow = createErrorSequenceFlow(boundaryEvent, errorEndEvent);
|
||||||
|
|
||||||
|
// 将错误处理相关的元素添加到流程中
|
||||||
|
process.addFlowElement(boundaryEvent);
|
||||||
|
process.addFlowElement(errorEndEvent);
|
||||||
|
process.addFlowElement(errorFlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建错误边界事件
|
||||||
|
*
|
||||||
|
* @param serviceTask 关联的服务任务
|
||||||
|
* @return 配置好的错误边界事件
|
||||||
|
*/
|
||||||
|
private BoundaryEvent createErrorBoundaryEvent(ServiceTask serviceTask) {
|
||||||
|
BoundaryEvent boundaryEvent = new BoundaryEvent();
|
||||||
|
boundaryEvent.setId(WorkFlowConstants.BOUNDARY_EVENT_ERROR_PREFIX + serviceTask.getId());
|
||||||
|
boundaryEvent.setAttachedToRef(serviceTask);
|
||||||
|
boundaryEvent.setAttachedToRefId(serviceTask.getId());
|
||||||
|
boundaryEvent.setCancelActivity(true); // 确保取消原有活动
|
||||||
|
|
||||||
|
// 配置错误事件定义
|
||||||
|
ErrorEventDefinition errorEventDefinition = new ErrorEventDefinition();
|
||||||
|
errorEventDefinition.setErrorCode(WorkFlowConstants.WORKFLOW_EXEC_ERROR);
|
||||||
|
boundaryEvent.addEventDefinition(errorEventDefinition);
|
||||||
|
|
||||||
|
return boundaryEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建错误结束事件
|
||||||
|
*
|
||||||
|
* @param serviceTask 关联的服务任务
|
||||||
|
* @return 配置好的错误结束事件
|
||||||
|
*/
|
||||||
|
private EndEvent createErrorEndEvent(ServiceTask serviceTask) {
|
||||||
|
EndEvent errorEndEvent = new EndEvent();
|
||||||
|
errorEndEvent.setId(WorkFlowConstants.END_EVENT_ERROR_PREFIX + serviceTask.getId());
|
||||||
|
|
||||||
|
// 添加终止定义
|
||||||
|
// TerminateEventDefinition terminateEventDefinition = new TerminateEventDefinition();
|
||||||
|
// errorEndEvent.addEventDefinition(terminateEventDefinition);
|
||||||
|
|
||||||
|
ErrorEventDefinition errorEventDefinition = new ErrorEventDefinition();
|
||||||
|
errorEventDefinition.setErrorCode(WorkFlowConstants.WORKFLOW_EXEC_ERROR);
|
||||||
|
errorEndEvent.addEventDefinition(errorEventDefinition);
|
||||||
|
|
||||||
|
return errorEndEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建错误处理流程的连线
|
||||||
|
*
|
||||||
|
* @param boundaryEvent 错误边界事件
|
||||||
|
* @param errorEndEvent 错误结束事件
|
||||||
|
* @return 配置好的连线
|
||||||
|
*/
|
||||||
|
private SequenceFlow createErrorSequenceFlow(BoundaryEvent boundaryEvent, EndEvent errorEndEvent) {
|
||||||
|
SequenceFlow errorFlow = new SequenceFlow();
|
||||||
|
errorFlow.setId(WorkFlowConstants.SEQUENCE_FLOW_ERROR_PREFIX + boundaryEvent.getAttachedToRefId());
|
||||||
|
errorFlow.setSourceRef(boundaryEvent.getId());
|
||||||
|
errorFlow.setTargetRef(errorEndEvent.getId());
|
||||||
|
|
||||||
|
return errorFlow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,15 @@ spring:
|
|||||||
always-use-message-format: false
|
always-use-message-format: false
|
||||||
use-code-as-default-message: true
|
use-code-as-default-message: true
|
||||||
cache-duration: 3600
|
cache-duration: 3600
|
||||||
|
flyway:
|
||||||
|
enabled: true
|
||||||
|
baseline-on-migrate: true
|
||||||
|
locations: classpath:db/migration
|
||||||
|
table: flyway_schema_history
|
||||||
|
baseline-version: 0
|
||||||
|
validate-on-migrate: true
|
||||||
|
placeholderPrefix: "#{"
|
||||||
|
placeholderSuffix: "}"
|
||||||
flowable:
|
flowable:
|
||||||
database-schema-update: true
|
database-schema-update: true
|
||||||
# id-generator: org.flowable.common.engine.impl.db.DbIdGenerator
|
# id-generator: org.flowable.common.engine.impl.db.DbIdGenerator
|
||||||
@ -62,10 +71,3 @@ jwt:
|
|||||||
|
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: Asia/Shanghai
|
time-zone: Asia/Shanghai
|
||||||
flyway:
|
|
||||||
enabled: true
|
|
||||||
baseline-on-migrate: true
|
|
||||||
locations: classpath:db/migration
|
|
||||||
table: flyway_schema_history
|
|
||||||
baseline-version: 0
|
|
||||||
validate-on-migrate: true
|
|
||||||
Loading…
Reference in New Issue
Block a user