Activiti - 信号和通话活动

时间:2017-01-25 14:59:32

标签: workflow activiti

这是我们的Activiti(版本5.21)主图: diagram 代码:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <signal id="alertSignal" name="alert"></signal>
  <process id="Call" name="Call" isExecutable="true">
    <callActivity id="callactivity1" name="Call activity 1" calledElement="Call1">
      <extensionElements>
    <activiti:in source="VARIABLE1" target="VARIABLE1"></activiti:in>
    <activiti:in source="VARIABLE2" target="VARIABLE2"></activiti:in>
       </extensionElements>
    </callActivity>
    <callActivity id="callactivity2" name="Call activity 2" calledElement="Call2">
      <extensionElements>
    <activiti:in source="VARIABLE1" target="VARIABLE1"></activiti:in>
    <activiti:in source="VARIABLE2" target="VARIABLE2"></activiti:in>
      </extensionElements>
    </callActivity>
    <callActivity id="callactivity3" name="Call activity 3" calledElement="Call3">
      <extensionElements>
    <activiti:in source="VARIABLE1" target="VARIABLE1"></activiti:in>
    <activiti:in source="VARIABLE2" target="VARIABLE2"></activiti:in>
      </extensionElements>
    </callActivity>
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="callactivity1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="callactivity1" targetRef="callactivity2"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="callactivity2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="callactivity3" targetRef="endevent2"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="callactivity1" cancelActivity="true">
      <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow5" sourceRef="boundarysignal1" targetRef="callactivity3"></sequenceFlow>
  </process>
</definitions>

第一个电话活动: diagram 2 代码:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <signal id="alertSignal" name="alert"></signal>
  <process id="Call1" name="Call1" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="test-a" name="test-a">
      <extensionElements>
    <activiti:taskListener event="create" expression="#{VARIABLE1.allow(task)}"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <userTask id="test-b" name="test-b">
      <extensionElements>
    <activiti:taskListener event="create" expression="#{VARIABLE1.allow(task)}"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="test-a"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="test-a" targetRef="parallelgateway1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="test-b"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="test-b" targetRef="endevent1"></sequenceFlow>
    <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
      <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
    </intermediateThrowEvent>
    <sequenceFlow id="flow5" sourceRef="parallelgateway1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
  </process>
</definitions>

事情是变量&#34; VARIABLE1&#34;和&#34; VARIABLE2&#34;没有被传递到&#34;呼叫活动2&#34;,我想边界信号可能有问题?因为他们被传递到&#34;呼叫活动1&#34;。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您如何知道变量未被发送到Call Activity 2? 您是否在流程启动时注入变量?

我问,因为如果你在进入Called Activity 1之前没有初始化过程变量,那么它们实际上并没有作为变量传递到子过程,而是在调用活动1的实例化时初始化它们子过程。

因此,如果变量在调用活动1的条目中不存在,则没有变量可以传递给调用活动2

这应该是一个相对简单的单元测试,用于演示哪些可以清除您的场景中的任何问题。

由于 格雷格