How to invoke various Child processes from a Parent process with out a call activity?

Hi All, I have a parent process - ProcessA from which I would like to initiate various Child processes - ChildA, ChildB, ChildC… I would like to know how to accomplish this with out using call activities?

Is there any specific reason you want to avoid Call Activities?

The first alternative that comes to mind would be a multi-instance send task which would send a message to trigger the child process. But in this cases you should be aware that there’s no parent child relationship as far as the engine in concerned

@startrek You can use message start events for starting child processes without call activity. As @Niall suggested you can use multi instance send task if you want to start multiple processes in parallel/sequential.

If it’s a choice between choosing the child processes to initiate, then refer the below example:

Deploy this bpmn file and start the parent process from tasklist: MessageStartEventTest.bpmn (9.8 KB)

Parent Process:

Child Process A:

Here’s a delegation code for correlating child process’s message start events:

@Slf4j
@Component
public class ChildProcessInvocationDelegate implements JavaDelegate {

	@Autowired
	private RuntimeService runtimeService;

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		log.info("Child process {} will be initiated...", execution.getVariable("childProcess"));
		ProcessInstance processInstance = runtimeService
				.createMessageCorrelation((String) execution.getVariable("childProcess"))
				.setVariable("referenceKey", execution.getVariable("referenceKey")).correlateStartMessage();
		runtimeService.setVariable(execution.getId(), "childProcessInstance_Id", processInstance.getId());
	}

}
1 Like

Thanks @Niall and @aravindhrs for your suggestions. I am trying to achieve this as below:

ProcessA:

ProcessB:

  1. From ProcessA, I should be able to initiate ProcessB and ProcessC at any point.
  2. On ProcessA, if I invoke a message to initiate ProcessB, I am trying to catch using the Message Catch Event, which should transfer the flow to the Message Throw Event
  3. In the Message Throw Event, I am sending a message i.e startProcessB, which is not working.

Am I doing something wrong here?

To be more precise, I want to start a child process from the parent by sending a message without the usage of Java delegate code. Not sure if this can be accomplished with Message Throw event or a Message Send Task as either of them didn’t work as desired

Hi @startrek,

you have to provide an implementation in your message throw event of process A to send the message.

You can use the code from @aravindhrs for this.

The message name that you defined in the process model is not used by the process engine.

Hope this helps, Ingo

Thanks @Ingo_Richtsmeier , so this can be achieved only through an implementation such as a Java delegate? I was thinking if this can be done using a much simpler way using an expression/delegate expression may be.

Hi @startrek,

a Java delegate is most basic implementation.

Of course you can abstract your code and choose a more loosly coupled way to bind it to the service task.

An expression like

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("myMessage").setVariable("name", "value").processInstanceBusinessKey("myBsuinessKey").correlate();

could do the same and trigger process B.

There are many possibilties to reach your goal, and the main message:
You need some code to send the message.

Hope this helps, Ingo

1 Like

Thank you @Ingo_Richtsmeier @Niall @aravindhrs ! Guess my assumptions are wrong then. I assumed that as the name indicates, one can directly send/throw a message through a Message Throw Event by specifying the message property on that event which would invoke a Message Start Event.