How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

cancel
Showing results for 
Search instead for 
Did you mean: 
sushant
Member II

How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Issue - At step 3, Subflow is not getting called in spite of configuration. Please provide any pointers. I do not want to call this child flow from  parent flow like below :

1 Solution

Accepted Solutions
gdharley
Intermediate

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hi Sushant, I tried what I had proposed and found it didnt work, so I checked the Activiti defect list.

Seems this is a known (unresolved) issue:

Issue Navigator - ACTIVITI-286 - Activiti: Event sub process not triggered with start signal thrown 

I suggest you vote up this issue so we can get it resolved.

Sorry,

Greg

View solution in original post

22 Replies
gdharley
Intermediate

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Before I "check your code", is there a specific reason you are trying to target a specific execution in your signalEventReceived call?

I ask because a simple inline signal throw event should trigger a deployed process that has a registered signal start event.

If you must use the signalEventReceived() method of runtimService, try using the global version (i.e. dont include an execution id).

Greg

sushant
Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hey Greg, Thanks for your reply.

No particular reason, I can make use of global version.

If I model my flow as per your suggestion and pic above, will the signal thrown be caught by subflow(refer my step 3 depiction) which is having signal start event ? assuming i do not explicitly need to call the subflow(like the un-preferred option shown in my original thread)

Please comment.

gdharley
Intermediate

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hey Sushant, if you use global signals, all process instances (including called sub processes) will pick up the signal.

Obviously there are always details that are specific to your scenario, but in terms of signals, global means global.

Hope this helps,

Greg

sushant
Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hi Greg,

I tried the option above, but my subflow is not getting invoked(may be because USer Task is blocking operation). Please do comment, here is the subflow configuration again

gdharley
Intermediate

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hi Sushant, I tried what I had proposed and found it didnt work, so I checked the Activiti defect list.

Seems this is a known (unresolved) issue:

Issue Navigator - ACTIVITI-286 - Activiti: Event sub process not triggered with start signal thrown 

I suggest you vote up this issue so we can get it resolved.

Sorry,

Greg

thuynh
Established Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hi Sushant,

While the signal start event is not working with 'event subprocess'. it is working if you have your signal-started process as standalone process. Is this acceptable workaround for you?

I have tested a few signal catching scenarios and they all worked except for the 'event subprocess' one. 

Also make sure that you DEPLOY all process definitions to have it work. For example,

public class SignalUnitTest {
Logger logger = Logger.getLogger(SignalUnitTest.class);
@Rule
public ActivitiRule activitiRule = new ActivitiRule();
@Test
@Deployment(resources = {"org/activiti/test/signal/signal-test-process.bpmn",
"org/activiti/test/signal/signal-catch-process.bpmn",
"org/activiti/test/signal/signal-start-process.bpmn"})
public void test() throws InterruptedException {
RuntimeService runtimeService = activitiRule.getRuntimeService();

.

.

.

}}

Here are my test scenarios,

Firstly, I have a process to throw a signal event

Then I have another process to catch that signal event as a start event (remember to configure the signal name correctly. Have a look at my attached process def xml)

And another catching process in which the signal event is an intermediate event

Here is my unit test run log. See the highlighted lines. They show that the error service task in the catching processes were executed. 

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.activiti.signal.SignalUnitTest
12:16:26,342 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [activiti.cfg.xml]
12:16:28,542 [main] INFO org.activiti.engine.impl.db.DbSqlSession - performing create on engine with resource org/activiti/db/create/activiti.h2.create.engine.sql
12:16:28,765 [main] INFO org.activiti.engine.impl.db.DbSqlSession - performing create on history with resource org/activiti/db/create/activiti.h2.create.history.sql
12:16:28,765 [main] INFO org.activiti.engine.impl.db.DbSqlSession - performing create on identity with resource org/activiti/db/create/activiti.h2.create.identity.sql
12:16:28,781 [main] INFO org.activiti.engine.impl.ProcessEngineImpl - ProcessEngine default created
12:16:28,828 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-test-process.bpmn
12:16:29,452 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-catch-process.bpmn
12:16:29,608 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-start-process.bpmn
12:16:29,812 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- START SIGNAL CATCH PROCESS -------------------------
12:16:29,874 [main] INFO org.activiti.signal.SignalUnitTest - Execution counts: 2
12:16:29,890 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 12
12:16:29,890 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 14
12:16:34,897 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- START SIGNAL TEST PROCESS -------------------------
12:16:34,897 [main] INFO org.activiti.signal.SignalServiceTask - SingalServiceTask execution : 17
12:16:34,929 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalCatchProcess:1:9
12:16:34,945 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalStartProcess:1:10
12:16:34,976 [main] INFO org.activiti.signal.SignalUnitTest - Process instance id: 17
12:16:39,984 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- CHECK SIGNAL CATCH PROCESS -------------------------

I have attached my unit test zip.

Hope this helps.

Thanks,

Thong Huynh

bp3‌

sushant
Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hey Thong,

This is a problem with User Task(you box seems Java Service Task), if you have " Throw Signal" event after a user task, that wont be called unless you do an action.(which is not the use case for me).

This is why, i had to configure a listener to generate an event without getting blocked. Now,this generated event is not caught by Subflow's start signal event. This is what is bug, as Greg mentioned.

Thanks and Regards,

Sushant

sushant
Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Any idea, if this is fixed in 5.x version ?

thuynh
Established Member II

Re: How to trigger a Sub flow using "Signal Event" which is getting generated in Parent Flow ?

Jump to solution

Hi Sushant,

I tried user task and it also works for me. Do you have a unit test for us to inspect why it's not working for you?

Unit Test Log

-----------------------------------------------------------------------------------------------------------------------------------------

10:00:55,585 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-test-process.bpmn
10:00:56,178 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-usertask-process.bpmn
10:00:56,365 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-catch-process.bpmn
10:00:56,523 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-start-process.bpmn
10:00:56,726 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- START SIGNAL CATCH PROCESS -------------------------
10:00:56,788 [main] INFO org.activiti.signal.SignalUnitTest - Execution counts: 2
10:00:56,788 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 15
10:00:56,788 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 17
10:01:01,796 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- START SIGNAL TEST PROCESS -------------------------
10:01:01,828 [main] INFO org.activiti.signal.SignalUnitTest - Process instance id: 20
10:01:01,844 [main] INFO org.activiti.signal.SignalUnitTest - Open task : 24 - Review Create Subscription Failure / assigned to: kermit
10:01:01,890 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalStartProcess:1:13
10:01:01,906 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalCatchProcess:1:12
10:01:06,945 [main] INFO org.activiti.signal.SignalUnitTest - ------------------------- CHECK SIGNAL CATCH PROCESS -------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.371 sec

Thank you,

Thong Huynh