cancel
Showing results for 
Search instead for 
Did you mean: 

Process with many nonestart events with different initiators

udoderk
Champ in-the-making
Champ in-the-making
Greeting activiti friends Smiley Happy

Some business process has a many none start events, that ordered to different swim lanes. In other words each none start event can be started by one and only one initiator like that "diagram":
_________________________________________________________________
(start event 1, owner "kermit" )…set of tasks from A to F…..    ————–>   (end event)
__________________________________________________________________…..^
(start event 2, owner "piggy") set of tasks from Cto F…———————————|
__________________________________________________________________

How can i model that process using Activiti (Explorer)?? If i try to deply such process, the deployment will be failed with message "multiple none start events or timer start events not supported on process definition".
That error is set in this method:
org.activiti.engine.impl.bpmn.parser.BpmnParse.selectInitial(List<ActivityImpl>, ProcessDefinitionEntity, Element)
  protected void selectInitial(List<ActivityImpl> startEventActivities, ProcessDefinitionEntity processDefinition, Element parentElement) {
    ActivityImpl initial = null;
    // validate that there is s single none start event / timer start event:
    for (ActivityImpl activityImpl : startEventActivities) {
      if(!activityImpl.getProperty("type").equals("messageStartEvent")) {
        if(initial == null) {
          initial = activityImpl;         
        } else {
          addError("multiple none start events or timer start events not supported on process definition", parentElement);
        }
      }
    }
    // if there is a single start event, select it as initial, regardless of it's type:
    if(initial == null && startEventActivities.size() == 1) {
      initial = startEventActivities.get(0);
    }
    processDefinition.setInitial(initial);
  }

Thanks a lot….
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
You can use multiple message-start events (http://activiti.org/userguide/index.html#bpmnMessageStartEvent) on your process. Instead of just calling startProcessInstance, you'll have to use startProcessInstanceByMessage(String messageName);.

If you want to use explorer (and you don't control what API-call is done when starting a process), you're only option is to use the activiti:initiator="${initiator}" construct with a single none-start-event and a exclusive-gateway which decides based on the "initiator" variable, which path to take.

udoderk
Champ in-the-making
Champ in-the-making
You can use multiple message-start events (http://activiti.org/userguide/index.html#bpmnMessageStartEvent) on your process. Instead of just calling startProcessInstance, you'll have to use startProcessInstanceByMessage(String messageName);.

If you want to use explorer (and you don't control what API-call is done when starting a process), you're only option is to use the activiti:initiator="${initiator}" construct with a single none-start-event and a exclusive-gateway which decides based on the "initiator" variable, which path to take.

thank you in advance for your help and tip with "${initiator} variable!

I test it solution with success! I tested also the approach without gateway, only with conditional flows "Exclusive Flows without Gateways"

P.S The example of use with gateway:

<?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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">
  <process id="myProcess333" name="My process 333" isExecutable="true">
    <startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="exclusivegateway1"></sequenceFlow>
    <userTask id="usertask1" name="User Task 1" activiti:assignee="kermit" activiti:candidateUsers="kermit">
      <extensionElements>
        <activiti:formProperty id="idkermit111" name="kermit tst 1" type="string" readable="false" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" sourceRef="exclusivegateway1" targetRef="usertask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${initiator == 'kermit'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask2" name="User Task I" activiti:assignee="fozzie" activiti:candidateUsers="fozzie">
      <extensionElements>
        <activiti:formProperty id="id111" name="test fozzie I" type="string" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="exclusivegateway1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${initiator == 'fozzie'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask3" name="User Task 2" activiti:assignee="kermit" activiti:candidateUsers="kermit"></userTask>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="usertask3"></sequenceFlow>
    <userTask id="usertask4" name="User Task II" activiti:assignee="fozzie" activiti:candidateUsers="fozzie">
      <extensionElements>
        <activiti:formProperty id="id222" name="fozzie test II" type="long" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow5" sourceRef="usertask2" targetRef="usertask4"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow6" sourceRef="usertask3" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="usertask4" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess333" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="40.0" y="140.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="120.0" y="137.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="210.0" y="50.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="205.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="370.0" y="50.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="365.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="530.0" y="60.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="75.0" y="157.0"></omgdi:waypoint>
        <omgdi:waypoint x="120.0" y="157.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="140.0" y="137.0"></omgdi:waypoint>
        <omgdi:waypoint x="262.0" y="105.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="160.0" y="157.0"></omgdi:waypoint>
        <omgdi:waypoint x="205.0" y="157.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="315.0" y="77.0"></omgdi:waypoint>
        <omgdi:waypoint x="370.0" y="77.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="310.0" y="157.0"></omgdi:waypoint>
        <omgdi:waypoint x="365.0" y="157.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="475.0" y="77.0"></omgdi:waypoint>
        <omgdi:waypoint x="530.0" y="77.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="470.0" y="157.0"></omgdi:waypoint>
        <omgdi:waypoint x="547.0" y="157.0"></omgdi:waypoint>
        <omgdi:waypoint x="547.0" y="95.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

…And without gateway:
<?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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">
  <process id="myProcess333wg" name="My process 333wgwy">
    <startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
    <userTask id="usertask1" name="User Task 1" activiti:assignee="kermit" activiti:candidateUsers="kermit">
      <extensionElements>
        <activiti:formProperty id="idkermit111" name="kermit tst 1" type="string" required="true" readable="false"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <userTask id="usertask2" name="User Task I" activiti:assignee="fozzie" activiti:candidateUsers="fozzie">
      <extensionElements>
        <activiti:formProperty id="id111" name="test fozzie I" type="string" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <userTask id="usertask3" name="User Task 2" activiti:assignee="kermit" activiti:candidateUsers="kermit"></userTask>
    <userTask id="usertask4" name="User Task II" activiti:assignee="fozzie" activiti:candidateUsers="fozzie">
      <extensionElements>
        <activiti:formProperty id="id222" name="fozzie test II" type="long" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow4" name="" sourceRef="usertask1" targetRef="usertask3"></sequenceFlow>
    <sequenceFlow id="flow5" name="" sourceRef="usertask2" targetRef="usertask4"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="usertask3" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow7" name="" sourceRef="usertask4" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow8" name="" sourceRef="startevent1" targetRef="usertask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${initiator == 'kermit'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow9" name="" sourceRef="startevent1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${initiator == 'fozzie'}]]></conditionExpression>
    </sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess333wg">
    <bpmndi:BPMNPlane bpmnElement="myProcess333wg" id="BPMNPlane_myProcess333wg">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="40" y="140"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55" width="105" x="210" y="50"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55" width="105" x="205" y="130"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55" width="105" x="370" y="50"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55" width="105" x="365" y="130"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="530" y="60"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="315" y="77"></omgdi:waypoint>
        <omgdi:waypoint x="370" y="77"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="310" y="157"></omgdi:waypoint>
        <omgdi:waypoint x="365" y="157"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="475" y="77"></omgdi:waypoint>
        <omgdi:waypoint x="530" y="77"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="470" y="157"></omgdi:waypoint>
        <omgdi:waypoint x="547" y="157"></omgdi:waypoint>
        <omgdi:waypoint x="547" y="95"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="57" y="140"></omgdi:waypoint>
        <omgdi:waypoint x="262" y="105"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="75" y="157"></omgdi:waypoint>
        <omgdi:waypoint x="205" y="157"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>