AnsweredAssumed Answered

Activiti 6: Dynamic activityId and triggering a receive task

Question asked by donovanmuller on Dec 4, 2015
Latest reply on Dec 8, 2015 by jbarrez
So, struggling a bit to get this working as expected

We have multiple processes for different work flows, some contain either 1 or more receiveTasks

<receiveTask id="receivetask1" name="Receive Task"></receiveTask>


The test process we created : [startEvent->scriptTask-> receiveTask -> scriptTask -> endEvent]

The below code will start the process and trigger successfully as we pass in the id of "receivetask1".


                log.info("Starting process…");
                ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");

                Execution execution = runtimeService.createExecutionQuery()
                        .processDefinitionKey("myProcess")
                        .processInstanceId(processInstance.getId())
                        .activityId("receivetask1")
                        .singleResult();

                log.info("Execution id : " + execution.getId() + " - " + execution.getParentId() + " - " + execution.getActivityId());

                runtimeService.trigger(execution.getId());
                log.info("…Done.");


The problem is we don't always know the receiveTasks`s id, or there could be more than one in the process.

Questions
  1. Is there anyway to look up the id during runtime? Almost same as looking for the current user task and then trigger the task
  2.  
  3. did runtimeService.trigger(execution.getId()) replace runtimeService.signal(execution.getId())?
  4.  
  5. i see from previous posts in using rs.signal(e.id) needed a while loop with sleep in case it isn't yet available. Is this still needed?  <a href="https://github.com/Activiti/Activiti/blob/activiti6/modules/activiti-camel/src/main/java/org/activiti/camel/ActivitiProducer.java">example from camel component</a>

Outcomes