From 89e390f102eafde8bc2c551645819c073021a475 Mon Sep 17 00:00:00 2001 From: wangli <274027703@qq.com> Date: Tue, 18 Jun 2024 15:00:41 +0800 Subject: [PATCH] =?UTF-8?q?update(REQ-2516)=20-=20=E8=B0=83=E6=95=B4=20Com?= =?UTF-8?q?plexInvokeClient=20=E7=9A=84=E5=93=8D=E5=BA=94=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/api/WorkflowManageService.java | 4 ++++ .../exception/WorkflowRpcInvokeException.java | 21 +++++++++++++++++++ .../ext/WorkflowEngineStarterDecoder.java | 7 ++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/common/exception/WorkflowRpcInvokeException.java diff --git a/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/api/WorkflowManageService.java b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/api/WorkflowManageService.java index 7f8a7d548..78809f2da 100644 --- a/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/api/WorkflowManageService.java +++ b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/api/WorkflowManageService.java @@ -239,6 +239,7 @@ public interface WorkflowManageService { @Operation(summary = "创建审批流程并带上表单") @PostMapping("/api/process/instance/form/create") @Manageable + @InvokeMode(SYNC) String createProcessInstanceWith(@Validated @RequestBody BpmnProcessInstanceCreateWithFormDTO dto); /** @@ -487,6 +488,7 @@ public interface WorkflowManageService { * 为指定流程新增变量 */ @PostMapping("/api/process/variable/create/{executionId}") + @InvokeMode(SYNC) Void createVariable(@PathVariable @NotBlank(message = "流程实例 ID 不能为空") String executionId, @RequestBody @Validated RestBpmnProcessVariable restVariable); /** @@ -497,12 +499,14 @@ public interface WorkflowManageService { * @return */ @PostMapping("/api/process/variable/update/{executionId}") + @InvokeMode(SYNC) Void updateVariable(@PathVariable @NotBlank(message = "流程实例 ID 不能为空") String executionId, @RequestBody @Validated RestBpmnProcessVariable restVariable); /** * 批量删除流程变量 */ @DeleteMapping("/api/process/variable/delete/{executionId}") + @InvokeMode(SYNC) Void deleteVariables(@PathVariable("executionId") String executionId, @RequestParam String variableNames, @RequestParam(value = "scope", required = false) String scope); /** diff --git a/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/common/exception/WorkflowRpcInvokeException.java b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/common/exception/WorkflowRpcInvokeException.java new file mode 100644 index 000000000..4ffde34dc --- /dev/null +++ b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/common/exception/WorkflowRpcInvokeException.java @@ -0,0 +1,21 @@ +package cn.axzo.workflow.starter.common.exception; + +/** + * Starter 的 RPC 动作调用异常 + * + * @author wangli + * @since 2024/6/18 14:20 + */ +public class WorkflowRpcInvokeException extends WorkflowEngineStarterException { + public WorkflowRpcInvokeException(Throwable cause) { + super(cause); + } + + public WorkflowRpcInvokeException(String message) { + super(message); + } + + public WorkflowRpcInvokeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/feign/ext/WorkflowEngineStarterDecoder.java b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/feign/ext/WorkflowEngineStarterDecoder.java index 065696f47..78cf7d339 100644 --- a/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/feign/ext/WorkflowEngineStarterDecoder.java +++ b/workflow-engine-spring-boot-starter/src/main/java/cn/axzo/workflow/starter/feign/ext/WorkflowEngineStarterDecoder.java @@ -1,5 +1,7 @@ package cn.axzo.workflow.starter.feign.ext; +import cn.axzo.workflow.starter.common.exception.WorkflowEngineStarterException; +import cn.axzo.workflow.starter.common.exception.WorkflowRpcInvokeException; import cn.azxo.framework.common.model.CommonResponse; import com.google.common.collect.Lists; import feign.Response; @@ -72,7 +74,10 @@ final class WorkflowEngineStarterDecoder implements Decoder { if (decode instanceof CommonResponse) { CommonResponse commonResponse = (CommonResponse) decode; if (response.status() == 202) { - log.error("workflow engine starter rpc invoke return msg: {}", commonResponse.getMsg()); + log.warn("workflow engine starter rpc invoke return msg: {}", commonResponse.getMsg()); + throw new WorkflowRpcInvokeException(commonResponse.getMsg()); + } else { + log.error("WorkflowEngineStarterDecoder has error, status:{} msg: {}", response.status(), commonResponse.getMsg()); } return commonResponse.getData(); }