Starting new process instance from another process - messages

Hi guys,
I’m trying to start a new process from another process. I’m using messages.

send_message.bpmn (7.2 KB)
process_with_start_signal_event.bpmn (12.5 KB)

I know how to start a process by sending a message (using REST API), but there is something wrong with throwing a message inside process.

Thanks for any help.

2 Likes

You’re going to need some kind of code to send the message - the message cannot be send without calling the API explicitly.

So you need to add an implementation type to your message event:

3 Likes

@dikey94, here is a easy way get you started:

Use implementation: expression

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("MyMessage").correlateWithResult()}

You can see other options for the Runtime Service:

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.6/org/camunda/bpm/engine/RuntimeService.html

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.6/org/camunda/bpm/engine/RuntimeService.html#correlateMessage(java.lang.String)

3 Likes

Thank you guys for your time. Really appreciate.

I’ve used a signal to start another process but both solutions are good.

Regards!

@dikey94, just FYI if you need to pass variables to the signalled process then take a look at the Message’s input parameters

1 Like

Good to know. Thanks!

is that possible to share those 2 bpmn files here please, i tried it a lot, doesnt seem to be working. guess im missing something.

Hi @Nishant_Agrawal,

have a look at this example: https://github.com/camunda-consulting/messaging-example

Hope this helps, Ingo

1 Like

Hi @Niall- I assume the call to child process is going to be asynchronous. I have tried a similar implementation where parent process runs a loop to trigger multiple child processes via send message event.
The purpose of using this over call activity was to have multiple instances triggered asynchronously, however each instance of the child process is waiting for completion before the next instances begins.

Any advise would be really helpfull.

Thanks:
Satish

By default it will start them async. to create transaction boundaries for each instance use the asynchronous before tick box on the start event of the process you’re calling.

Thank @Niall, basically I do not want the child process instance to wait for completion before next one triggers. If parent process has triggered 30 send messages via a loop I would like all the 30 instances to be triggered parallely. How can that be achieved?

Yup, what i suggested would achieve that.

YES!!! this is exactly what I needed. Was pulling my hair out trying to figure out how to make this work using the job executor and job priority and some weird hacks with bpm.

Does Camunda consider it bad practice to start a process instance from another process instance with Java code vs. an explicit call activity or embedded sub-process?

The reason I do it is because if one or two of the process instances in the child process definition (prcs def that is triggered with java api from a delegate) creates an incident I don’t want to lock up the calling parent process. I also don’t want to loose any of the nested child process instances if they aren’t successful right away. My understanding is that with call activities and nested sub-process (that are multi instance) if any instances fail or don’t complete they will be deleted when the parent process moves on to the next token.

The parent would not move on to the next activity until all call activity of embedded sub processes were completed. They are just extensions of the parent process. But using messages is non blocking and not connected like how call activities are.