cancel
Showing results for 
Search instead for 
Did you mean: 

Continue execution without completing a subprocess

mduffour
Champ in-the-making
Champ in-the-making
Hi guys, we want to know if is it possible to continue a process execution if a subprocess is not completed.

For example, we have a subprocess A and a subprocess B like this, A->B. A has two end nodes, one is executed and the other is waiting for a user task to be completed. So i guess the subprocess A is not completed, but we want that the execution continues and starts B anyway.

The thing is that we are looking for the minimal impact solution, cause we have a huge workflow already on production, were we want to add subprocess's.

What do you guys recommend in such scenario ? How process/execution/tasks variables works in this scenario ?


Thanks,
Regards,
Mateo.
8 REPLIES 8

warper
Star Contributor
Star Contributor
Hi Mateo!
From bpmn point of view it's not possible - subprocess does not release control before all its executions finish.
On the other side it's not that important what execution continues work. You can spawn execution for B beforehand and send singal from subprocess A to execution for B whenever you want.
If you want to pass variables from A to B, you can pass some in signal, but it has to be synchronous signal then. Note that synchronous singal send will block execution A for synchronous time and in worst case merge transactions, so it might be helpful to set async step just after signal catching event.

mduffour
Champ in-the-making
Champ in-the-making
Hi Warper, thanks for the fast feedback.

I added an intermediate throwing event in subprocess A and an intermediate catching event at process level which flows into subprocess B, but when i tried to deploy it gave me an error related to a signalref missing. So i manually added a signal and a signal ref to the xml. I could deploy, but the intermediate catching is never called. Here is the test case https://i.stack.imgur.com/MtoeT.png

Im not using a Signal Start Event in an Event Sub process, because there is an open defect on this use case: https://issues.alfresco.com/jira/browse/ACTIVITI-286

warper
Star Contributor
Star Contributor
Hi mduffour!
You did not spawn execution for B beforehand. IntermediateCatchigEvent does not work as singal start event, this block should have incoming sequence flow.
Also, signal throwing event is global, it sends signal to every process, you should change it to service task with engine request in java code that sends signal to one particular process execution (the one in your current process).
Also, it's good idea to have outcoming sequence flow from signal throwing block, leading to end

mduffour
Champ in-the-making
Champ in-the-making
Ok thanks again warper!, i replaced the intermediate catch signal event with a signal start event and it worked, but i get 2 independent process not sharing variables. How do i get the variables of A in B? And how do i know which process's belong together (A and B parent process ?) ?

I'll attach the bpmn:

<code>
<?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" 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">
<signal id="alertSignal" name="alert" />
  <process id="myProcess" name="myProcess" isExecutable="true">
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent1" name="End"></endEvent>
      <userTask id="verifico-id-transitorio-paciente" name="verifico-id-transitorio-paciente">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow1" sourceRef="startevent2" targetRef="verifico-id-transitorio-paciente"></sequenceFlow>
      <sequenceFlow id="flow2" sourceRef="verifico-id-transitorio-paciente" targetRef="parallelgateway1"></sequenceFlow>
      <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
      <sequenceFlow id="flow10" sourceRef="parallelgateway1" targetRef="ingreso-formulario-ConMed"></sequenceFlow>
      <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
        <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
      </intermediateThrowEvent>
      <sequenceFlow id="flow11" sourceRef="parallelgateway1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
      <userTask id="ingreso-formulario-ConMed" name="ingreso-formulario-ConMed">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow13" sourceRef="ingreso-formulario-ConMed" targetRef="endevent1"></sequenceFlow>
    </subProcess>
    <subProcess id="subprocess2" name="Sub Process">
      <startEvent id="startevent3" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <userTask id="ingreso-formulario-Con" name="ingreso-formulario-Con">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow5" sourceRef="startevent3" targetRef="ingreso-formulario-Con"></sequenceFlow>
      <sequenceFlow id="flow6" sourceRef="ingreso-formulario-Con" targetRef="endevent2"></sequenceFlow>
    </subProcess>
    <startEvent id="startevent1" name="Start"></startEvent>
    <subProcess id="subprocess3" name="Sub Process">
      <userTask id="modifico-formulario-ConMed" name="modifico-formulario-ConMed">
        <extensionElements>
        </extensionElements>
      </userTask>
      <startEvent id="startevent4" name="Start"></startEvent>
      <endEvent id="endevent3" name="End"></endEvent>
      <sequenceFlow id="flow8" sourceRef="startevent4" targetRef="modifico-formulario-ConMed"></sequenceFlow>
      <sequenceFlow id="flow9" sourceRef="modifico-formulario-ConMed" targetRef="endevent3"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="subprocess1" targetRef="subprocess2"></sequenceFlow>
    <endEvent id="endevent4" name="End"></endEvent>
    <sequenceFlow id="flow7" sourceRef="subprocess2" targetRef="endevent4"></sequenceFlow>
    <startEvent id="signalstartevent1" name="Signal start">
      <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
    </startEvent>
    <sequenceFlow id="flow14" sourceRef="signalstartevent1" targetRef="subprocess3"></sequenceFlow>
  </process>
</definitions>

</code>

warper
Star Contributor
Star Contributor
Hi mduffour!
Signal start event spawns new process, it's not what you want.
You can use non-cancelling coundary event catching event to spawn new execution within this process. Something like this.
<code>
<?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" 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">
  <signal id="alertSignal" name="alert" activiti:scope="processInstance"></signal>
  <process id="myProcess" name="myProcess" isExecutable="true">
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent1" name="End"></endEvent>
      <userTask id="verifico-id-transitorio-paciente" name="verifico-id-transitorio-paciente">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow1" sourceRef="startevent2" targetRef="verifico-id-transitorio-paciente"></sequenceFlow>
      <sequenceFlow id="flow2" sourceRef="verifico-id-transitorio-paciente" targetRef="parallelgateway1"></sequenceFlow>
      <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
      <sequenceFlow id="flow10" sourceRef="parallelgateway1" targetRef="ingreso-formulario-ConMed"></sequenceFlow>
      <userTask id="ingreso-formulario-ConMed" name="ingreso-formulario-ConMed">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow13" sourceRef="ingreso-formulario-ConMed" targetRef="endevent1"></sequenceFlow>
      <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
        <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
      </intermediateThrowEvent>
      <sequenceFlow id="flow20" sourceRef="parallelgateway1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
    </subProcess>
    <subProcess id="subprocess2" name="Sub Process">
      <startEvent id="startevent3" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <userTask id="ingreso-formulario-Con" name="ingreso-formulario-Con">
        <extensionElements>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener>
          <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow5" sourceRef="startevent3" targetRef="ingreso-formulario-Con"></sequenceFlow>
      <sequenceFlow id="flow6" sourceRef="ingreso-formulario-Con" targetRef="endevent2"></sequenceFlow>
    </subProcess>
    <startEvent id="startevent1" name="Start"></startEvent>
    <subProcess id="subprocess3" name="Sub Process">
      <userTask id="modifico-formulario-ConMed" name="modifico-formulario-ConMed"></userTask>
      <startEvent id="startevent4" name="Start"></startEvent>
      <endEvent id="endevent3" name="End"></endEvent>
      <sequenceFlow id="flow8" sourceRef="startevent4" targetRef="modifico-formulario-ConMed"></sequenceFlow>
      <sequenceFlow id="flow9" sourceRef="modifico-formulario-ConMed" targetRef="endevent3"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow4" sourceRef="subprocess1" targetRef="subprocess2"></sequenceFlow>
    <endEvent id="endevent4" name="End"></endEvent>
    <sequenceFlow id="flow7" sourceRef="subprocess2" targetRef="endevent4"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="subprocess1" cancelActivity="false">
      <signalEventDefinition signalRef="alertSignal"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow19" sourceRef="boundarysignal1" targetRef="subprocess3"></sequenceFlow>
    <endEvent id="endevent5" name="End"></endEvent>
    <sequenceFlow id="flow21" sourceRef="subprocess3" targetRef="endevent5"></sequenceFlow>
    <sequenceFlow id="flow22" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1">
        <omgdc:Bounds height="230.0" width="540.0" x="135.0" y="3.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent2" id="BPMNShape_startevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="160.0" y="102.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="620.0" y="90.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="verifico-id-transitorio-paciente" id="BPMNShape_verifico-id-transitorio-paciente">
        <omgdc:Bounds height="60.0" width="100.0" x="235.0" y="90.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="385.0" y="102.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ingreso-formulario-ConMed" id="BPMNShape_ingreso-formulario-ConMed">
        <omgdc:Bounds height="60.0" width="100.0" x="475.0" y="23.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="signalintermediatethrowevent1" id="BPMNShape_signalintermediatethrowevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="485.0" y="163.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarysignal1" id="BPMNShape_boundarysignal1">
        <omgdc:Bounds height="30.0" width="30.0" x="488.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess2" id="BPMNShape_subprocess2">
        <omgdc:Bounds height="100.0" width="300.0" x="750.0" y="68.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent3" id="BPMNShape_startevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="770.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="1000.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ingreso-formulario-Con" id="BPMNShape_ingreso-formulario-Con">
        <omgdc:Bounds height="60.0" width="100.0" x="850.0" y="88.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="0.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess3" id="BPMNShape_subprocess3">
        <omgdc:Bounds height="100.0" width="300.0" x="540.0" y="304.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="modifico-formulario-ConMed" id="BPMNShape_modifico-formulario-ConMed">
        <omgdc:Bounds height="60.0" width="100.0" x="640.0" y="324.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent4" id="BPMNShape_startevent4">
        <omgdc:Bounds height="35.0" width="35.0" x="560.0" y="336.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="780.0" y="336.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent4" id="BPMNShape_endevent4">
        <omgdc:Bounds height="35.0" width="35.0" x="1150.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent5" id="BPMNShape_endevent5">
        <omgdc:Bounds height="35.0" width="35.0" x="900.0" y="336.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="195.0" y="119.0"></omgdi:waypoint>
        <omgdi:waypoint x="235.0" y="120.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="335.0" y="120.0"></omgdi:waypoint>
        <omgdi:waypoint x="385.0" y="122.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="405.0" y="102.0"></omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="53.0"></omgdi:waypoint>
        <omgdi:waypoint x="475.0" y="53.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="575.0" y="53.0"></omgdi:waypoint>
        <omgdi:waypoint x="587.0" y="53.0"></omgdi:waypoint>
        <omgdi:waypoint x="637.0" y="53.0"></omgdi:waypoint>
        <omgdi:waypoint x="637.0" y="90.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow20" id="BPMNEdge_flow20">
        <omgdi:waypoint x="405.0" y="142.0"></omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="180.0"></omgdi:waypoint>
        <omgdi:waypoint x="485.0" y="180.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="805.0" y="117.0"></omgdi:waypoint>
        <omgdi:waypoint x="850.0" y="118.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="950.0" y="118.0"></omgdi:waypoint>
        <omgdi:waypoint x="1000.0" y="117.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="595.0" y="353.0"></omgdi:waypoint>
        <omgdi:waypoint x="640.0" y="354.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="740.0" y="354.0"></omgdi:waypoint>
        <omgdi:waypoint x="780.0" y="353.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="675.0" y="118.0"></omgdi:waypoint>
        <omgdi:waypoint x="750.0" y="118.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="1050.0" y="118.0"></omgdi:waypoint>
        <omgdi:waypoint x="1150.0" y="117.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow19" id="BPMNEdge_flow19">
        <omgdi:waypoint x="503.0" y="250.0"></omgdi:waypoint>
        <omgdi:waypoint x="502.0" y="356.0"></omgdi:waypoint>
        <omgdi:waypoint x="540.0" y="354.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow21" id="BPMNEdge_flow21">
        <omgdi:waypoint x="840.0" y="354.0"></omgdi:waypoint>
        <omgdi:waypoint x="900.0" y="353.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow22" id="BPMNEdge_flow22">
        <omgdi:waypoint x="35.0" y="117.0"></omgdi:waypoint>
        <omgdi:waypoint x="135.0" y="118.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</code>

I've changed event scope to ProcessInstance, added non-cancelling boundary catching event. Unfortunately it will not work well unless you make event-related part asynchronous and non-exclusive. If it's all synchronous and exclusive, activiti will do process steps one by one in one thread, and subprocess work will not be possible in parallel with main process synchronous part, and main process asynchronous part will not be able to run unless subprocess execution finishes.

mduffour
Champ in-the-making
Champ in-the-making
Execelent, that worked!

One last question, is it possible to achieve this behavior with process's instead of executions ?. In other words, subprocess's beeing actual process's and not executions. And those process's have a common parent process, is that even possible ?

warper
Star Contributor
Star Contributor
It's possible, but I don't think border events will work. Instead of border signal you can send signal through java code. Activiti runtimeService can send signal with attached variables to any execution waiting for such signal, you only need to find recipient process (it's execution dedicated to signal catching) through execution query.
I'm working on project that sends signals through special rest interface. It makes execution query with filters on orderId and signal name,  then sends signal. Additional/updated variables are passed through. You cannot use asynchronous signal here if you want to pass variables, but making calling part asynchronous is not so big deal.
Parent:
<code>
<?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" 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">
  <signal id="alert" name="alert" activiti:scope="global"></signal>
  <process id="parentWithSignalCatch" name="parentWithSignalCatch" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway" activiti:async="true"></parallelGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <callActivity id="callactivity1" name="Call activity" calledElement="subProcessSendingSignal">
      <extensionElements>
        <activiti:in source="key" target="key"></activiti:in>
        <activitiSmiley Surprisedut source="fullResult" target="fullResult"></activitiSmiley Surprisedut>
      </extensionElements>
    </callActivity>
    <sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="callactivity1"></sequenceFlow>
    <intermediateCatchEvent id="signalintermediatecatchevent1" name="SignalCatchEvent">
      <signalEventDefinition signalRef="alert"></signalEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="signalintermediatecatchevent1"></sequenceFlow>
    <serviceTask id="servicetask1" name="DoSomething" activiti:expression="#{doSomething(partialResult)}"></serviceTask>
    <sequenceFlow id="flow4" sourceRef="signalintermediatecatchevent1" targetRef="servicetask1"></sequenceFlow>
    <scriptTask id="scripttask1" name="generate unique key" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>key = java.util.UUID.randomUUID().toString();
execution.setVariable("key", key);</script>
    </scriptTask>
    <sequenceFlow id="flow5" sourceRef="scripttask1" targetRef="parallelgateway1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow6" sourceRef="callactivity1" targetRef="servicetask2"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow7" sourceRef="servicetask1" targetRef="endevent2"></sequenceFlow>
    <serviceTask id="servicetask2" name="DoSomethingElse" activiti:async="true" activiti:exclusive="false" activiti:expression="#{doSomethingElse}"></serviceTask>
    <sequenceFlow id="flow8" sourceRef="servicetask2" targetRef="endevent1"></sequenceFlow>
    <textAnnotation id="textannotation1">
      <text>Here we can get partialResult variabe in signal</text>
    </textAnnotation>
    <association id="association1" sourceRef="textannotation1" targetRef="signalintermediatecatchevent1"></association>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_parentWithSignalCatch">
    <bpmndi:BPMNPlane bpmnElement="parentWithSignalCatch" id="BPMNPlane_parentWithSignalCatch">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="50.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="250.0" y="167.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="callactivity1" id="BPMNShape_callactivity1">
        <omgdc:Bounds height="55.0" width="105.0" x="340.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="signalintermediatecatchevent1" id="BPMNShape_signalintermediatecatchevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="253.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="350.0" y="260.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55.0" width="105.0" x="110.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="750.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="640.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="520.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="textannotation1" id="BPMNShape_textannotation1">
        <omgdc:Bounds height="50.0" width="100.0" x="300.0" y="360.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="85.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="110.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="290.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="340.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="270.0" y="207.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="270.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="288.0" y="287.0"></omgdi:waypoint>
        <omgdi:waypoint x="350.0" y="287.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="215.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="445.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="520.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="455.0" y="287.0"></omgdi:waypoint>
        <omgdi:waypoint x="640.0" y="287.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="625.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="750.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="association1" id="BPMNEdge_association1">
        <omgdi:waypoint x="350.0" y="360.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="305.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</code>

SubProcess:
<code>
<?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" 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="subProcessSendingSignal" name="subProcessSendingSignal" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:expression="${doSomething}" activiti:resultVariableName="partialResult"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask2" name="Service Task" activiti:async="true" activiti:exclusive="false" activiti:expression="${soSomethingElse}" activiti:resultVariableName="fullResult"></serviceTask>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway" activiti:async="true" activiti:exclusive="false"></parallelGateway>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="parallelgateway1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="servicetask2"></sequenceFlow>
    <serviceTask id="servicetask3" name="Send Signal" activiti:async="true" activiti:exclusive="false" activiti:delegateExpression="myorg.myproject.SendSignalWithVars"></serviceTask>
    <endEvent id="endevent1" name="End" activiti:async="true"></endEvent>
    <sequenceFlow id="flow4" sourceRef="parallelgateway1" targetRef="servicetask3"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="servicetask3" targetRef="endevent1"></sequenceFlow>
    <endEvent id="endevent2" name="End" activiti:async="true"></endEvent>
    <sequenceFlow id="flow6" sourceRef="servicetask2" targetRef="endevent2"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_subProcessSendingSignal">
    <bpmndi:BPMNPlane bpmnElement="subProcessSendingSignal" id="BPMNPlane_subProcessSendingSignal">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="140.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="270.0" y="140.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="481.0" y="140.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="400.0" y="147.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55.0" width="105.0" x="368.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="403.0" y="350.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="630.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="175.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="270.0" y="167.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="375.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="167.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="440.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="481.0" y="167.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="420.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="420.0" y="250.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="420.0" y="305.0"></omgdi:waypoint>
        <omgdi:waypoint x="420.0" y="350.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="586.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="630.0" y="167.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</code>

Essential code for sending signal java delegate:
<code>
String key = execution.getVariable("key");
List<Execution> executions = runtimeService.createExecutionQuery()
    .signalEventSubscriptionName("alert")
    .processVariableValueEquals("key", key)
    .list();
HashMap<String, Object> singalVariables = new HashMap<>();
signalVariables.put("partialResult", execution.getVariable("partialResult"));
for (Execution execution : executions)
    runtimeService.signalEventReceived("alert", execution.getId(), signalVariables);
</code>

maudrid
Champ on-the-rise
Champ on-the-rise
I'm doing it with a script task like this:
<code>
var HashMap = Java.type('java.util.HashMap');
var variables = new HashMap();
variables.put('data', data);
var processInstance = runtimeService.startProcessInstanceByMessage('mymessage', variables);
</code>