3

我有一个看起来像这样的 Camunda 流程:

在此处输入图像描述

我使用 Exclusive Gateway 在我的工作流程中创建一个分支:当电子邮件已被确认时,我会继续,如果没有,我想确认它。

为了实现这一点,我在我的序列流中添加了以下条件:

<!-- GATEWAY -->
<bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="GO_TO_CONFIRM_EMAIL">
    <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
    <bpmn2:outgoing>GO_TO_CONFIRM_EMAIL</bpmn2:outgoing>
    <bpmn2:outgoing>GO_TO_IDENTIFY_ORDER</bpmn2:outgoing>
</bpmn2:exclusiveGateway>

<!-- DEFAULT FLOW -->
<bpmn2:sequenceFlow id="GO_TO_CONFIRM_EMAIL" name="!confirmed" sourceRef="ExclusiveGateway_1" targetRef="CONFIRM_EMAIL"/>

<!-- FLOW WITH CONDITION -->
<bpmn2:sequenceFlow id="GO_TO_IDENTIFY_ORDER" name="confirmed" sourceRef="ExclusiveGateway_1" targetRef="IDENTIFY_ORDER">
    <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${confirmEmailTaskAdapter.isConfirmed(CONFIRMED_ORDER_JSON)}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>

但是,当我运行它时,我得到以下异常:

org.camunda.bpm.engine.ProcessEngineException: Cannot construct activity-execution mapping: there are more scope executions missing than explained by the flow scope hierarchy.
    at org.camunda.bpm.engine.impl.pvm.runtime.LegacyBehavior.createActivityExecutionMapping(LegacyBehavior.java:294)
    at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createActivityExecutionMapping(PvmExecutionImpl.java:1211)
    at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createActivityExecutionMapping(PvmExecutionImpl.java:1144)
    at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior$ErrorDeclarationFinder.collect(AbstractBpmnActivityBehavior.java:248)
    at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior$ErrorDeclarationFinder.collect(AbstractBpmnActivityBehavior.java:223)
    at org.camunda.bpm.engine.impl.tree.TreeWalker.walkUntil(TreeWalker.java:72)
    at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.propagateError(AbstractBpmnActivityBehavior.java:124)
    at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.propagateExceptionAsError(AbstractBpmnActivityBehavior.java:94)
    at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior.execute(ServiceTaskExpressionActivityBehavior.java:64)
    at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:42)
    at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:27)
    at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:134)
    at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:494)
    at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:484)
    at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:464)
    ... and some more ...

但是,如果我将条件更改为非常简单的条件,则该过程有效:

<!-- THIS WORKS FINE -->
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${true}</bpmn2:conditionExpression>

我的 Spring Bean 看起来很正常:

@Component
public class ConfirmEmailTaskAdapter {
    public boolean isConfirmed(String json) {
        // bla bla bla
        return true;
    }
}

为什么在 Camunda 条件下不使用我的 Spring Bean 不起作用?

4

1 回答 1

3

由于它帮助了 Thomas,我将发布我的上述评论作为答案,尽管它不是解决该问题的技术解决方案。

不是一个解决方案,而是一个可能有助于解决问题的最佳实践:我们不使用动态服务调用来进行网关决策,只使用预先评估的流程变量。因此,在您的情况下,为什么不让 Listener 甚至 serviceTask 确定确认的值,将其写入流程变量,而不仅仅是在序列流上使用 ${isConfirmed} ...

于 2015-08-20T10:54:16.923 回答