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 :
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
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).
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.
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,
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
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();...}}
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.SignalUnitTest12: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.sql12: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.sql12: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.sql12:16:28,781 [main] INFO org.activiti.engine.impl.ProcessEngineImpl - ProcessEngine default created12:16:28,828 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-test-process.bpmn12:16:29,452 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-catch-process.bpmn12:16:29,608 [main] INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer - Processing resource org/activiti/test/signal/signal-start-process.bpmn12: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: 212:16:29,890 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 1212:16:29,890 [main] INFO org.activiti.signal.SignalUnitTest - Execution: null - 1412: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 : 1712:16:34,929 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalCatchProcess:1:912:16:34,945 [main] INFO org.activiti.signal.SendErrorService - SendErrorService executed. Process: signalStartProcess:1:1012:16:34,976 [main] INFO org.activiti.signal.SignalUnitTest - Process instance id: 1712: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
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
Any idea, if this is fixed in 5.x version ?
This remains a defect and doesnt appear to be fixed in the latest 5.x engine release.
In addition, it appears to be an issue in the version 6 Beta release as well.
Sushant,I opened up your package and I think we will need you to attach the TaskListener since this is what throws the signal.
com.pb.saase2e.cs.workflow.task.listener.UserTaskListenerIt appears the key piece was missing from the application package.
Thanks,Greg
Edited my post to include the listener java class. Here it is again
package com.pb.saase2e.cs.workflow.task.listener;
import org.activiti.engine.RuntimeService;import org.activiti.engine.delegate.DelegateTask;import org.activiti.engine.delegate.TaskListener;import org.slf4j.Logger;import org.slf4j.LoggerFactory;
public class UserTaskListener implements TaskListener {
private static final long serialVersionUID = 1L; private static Logger logger = LoggerFactory.getLogger(UserTaskListener.class);
@Override public void notify(DelegateTask delegateTask) {
RuntimeService runtimeService = delegateTask.getExecution().getEngineServices().getRuntimeService();
delegateTask.getExecution().setVariable("TaskId", delegateTask.getId()); delegateTask.getExecution().setVariable("TaskName", delegateTask.getName());
runtimeService.signalEventReceived("EMAIL_SUPPORT_SIGNAL"); logger.info("Sent signal event:{} for taskId:{} and taskName:{}", "EMAIL_SUPPORT_SIGNAL", delegateTask.getId(), delegateTask.getName());
Hey Sushant,
I am still trying to work out why the Signal is not being picked up.
But since you are calling the signal task from a Listener, I found a work around.
Rather than using a signal start event. Just use a regular start event.
Then, instead of sending the signal, simply start the sub process from the runtimeService using startProcessInstanceByKeyAndTenantId().I have attached an updated project with the work around implemented.Agreed, I dont like it and we need to work out why signals are not working in this scenario, but it shoudl get you moving.
Sushant, I spoke too soon.
The solution is actually very simple and is because it appears you are using Enterprise Edition rather than community edition.
You cannot call runtimeService.signalEventReceived() to trigger a signal start even in Enterprise edition UNLESS the process was deployed without a tenant id. By default, all deployments will include a tenant ID and the signalEventReceived includes the tenant ID in the query to locate subscriptions.
SO, ALL YOU NEED TO DO IS CHANGE YOUR RUNTIMESERVICE() CALL TO :
runtimeService.signalEventReceivedWithTenantId("EMAIL_SUPPORT_SIGNAL", "tenant_1");
Obviously if you are part of a different tenant, you would include that id.
I tested this and it worked immediately.
Thanks Greg, I got it working. Much Appreciated.
Hi Thuynh,
I was trying to create a trigger in my main flow that will be triggering sub flows. Now i am confused whether we can use timer event or sub process to achieve it?