cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Events across process definitions

shuchi
Champ in-the-making
Champ in-the-making
Hi,

I have a use-case where I have two process definitions and have to define a relationship between the two, say if process instance A1 of process definition A completes, it sends an event which is listened to by process instances of process definition B. When they receive the event sent by A1, they should perform some task.

Is this possible to achieve in Activiti?

Thanks,
Shuchi
7 REPLIES 7

shuchi
Champ in-the-making
Champ in-the-making
Can someone pl help me in this problem?

jbarrez
Star Contributor
Star Contributor
The thing you want is called a 'signal event' in Activiti. Read the docs for more info.

Signals are by default accross process instance boundaries

shuchi
Champ in-the-making
Champ in-the-making
Thanks, I tried with Boundary signal event and I am able to communicate between Process definitions. However, the receiving process instance has to be in the receiving state to receive a signal. Suppose, I am receiving the signal at a User Task state. My process instance needs to be at that User Task state to be able to receive the signal. If I want to still receive the signal when a process instance reaches the User Task state, how can that be achieved?

shuchi
Champ in-the-making
Champ in-the-making
Signal Throwing process

<process id="SignalThrowingProcess" name="SignalThrowingProcess" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task 1"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
      <signalEventDefinition signalRef="globalSignalThrowFromOnBoardingWorkflow"></signalEventDefinition>
    </intermediateThrowEvent>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
  </process>

Signal Receiving Process

<process id="SignalReceivingProcess" name="SignalReceivingProcess" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask2" name="User Task 2"></userTask>
    <userTask id="usertask3" name="User Task 3"></userTask>
    <boundaryEvent id="boundaryCatchingEvent" attachedToRef="usertask2" cancelActivity="false">
      <signalEventDefinition signalRef="globalSignalThrowFromOnBoardingWorkflow"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow2" sourceRef="boundaryCatchingEvent" targetRef="usertask3"></sequenceFlow>
    <userTask id="usertask1" name="User Task 1"></userTask>
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
  </process>

When the receiving process instance is not in userTask2 state and if a signal is thrown, the receiving process instance is not able to receive the signal even when it reached userTask2 state later. From what I understand, signals are only delivered to active handlers who are in the correct state.

How to receive signal even when a process instance has not started at the time of signal throwing or even if it is active, not in the state where it can act upon the signal received currently but when it reaches the appropriate receiving state, can act upon the signal.

Please help.

shuchi
Champ in-the-making
Champ in-the-making
Sorry, here are the process definitions for Signal Throwing process and Signal Receiving process.

Signal Throwing process:

<process id="SignalThrowingProcess" name="SignalThrowingProcess" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task 1"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
      <signalEventDefinition signalRef="globalSignalThrowFromOnBoardingWorkflow"></signalEventDefinition>
    </intermediateThrowEvent>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
  </process>
Signal Receiving process:

<process id="SignalReceivingProcess" name="SignalReceivingProcess" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask2" name="User Task 2"></userTask>
    <userTask id="usertask3" name="User Task 3"></userTask>
    <boundaryEvent id="boundaryCatchingEvent" attachedToRef="usertask2" cancelActivity="false">
      <signalEventDefinition signalRef="globalSignalThrowFromOnBoardingWorkflow"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow2" sourceRef="boundaryCatchingEvent" targetRef="usertask3"></sequenceFlow>
    <userTask id="usertask1" name="User Task 1"></userTask>
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
  </process>

jbarrez
Star Contributor
Star Contributor
If you want the signal to be received any time, simply add all your user tasks in an embedded subprocess with a signal boundary event.

shuchi
Champ in-the-making
Champ in-the-making
Thanks Joram!