AnsweredAssumed Answered

How to model/implement process with multiple start events

Question asked by lichtin on Sep 28, 2011
I have a scenario where different types of messages arrive in a more or less random order.
They conceptually belong together and need to be caught and handled within one process instance.
What is unclear to me, how can I do this with Activiti.

One idea: Define several start events with different Ids. The Ids would represent the different messages. For example:

  <process id="P">
    <startEvent id="MSG1" />
    <sequenceFlow id="FLOW11" sourceRef="MSG1" targetRef="SRV1" />
    <serviceTask id="SRV1" activiti:class="org.this.MyJavaDelegate1" />
    <sequenceFlow id="FLOW12" sourceRef="SRV1" targetRef="END1" />
    <endEvent id="END1" />
    <startEvent id="MSG2" />
    <sequenceFlow id="FLOW21" sourceRef="MSG2" targetRef="SRV2" />
    <serviceTask id="SRV2" activiti:class="org.this.MyJavaDelegate2" />
    <sequenceFlow id="FLOW22" sourceRef="SRV2" targetRef="END2" />
    <endEvent id="END2" />
To start the process, I would provide the Id of the start event to RuntimeService.startProcess*(startEventId).
Later, when another message arrives, I would signal this to the engine using something like RuntimeService.resumeProcess(…,startEventId)

As said, just an idea of how it could work.
Any thoughts, other ideas, how to implement this?