Newbie / Understanding message flow

Hi. I’m new to BPMN and trying to understand (in theory) the message flow and the correlation to process instances. What will be the “customer id” the intermediate catch message event in the upper pool receives? What will happen to the second message? Are 3 processes instantiated or will the start message event in the lower pool not start a new process instance?

I know this example process is stupid - it’s just to illustrate the issue…

Thanks for any help!
Christian


diagram_1.bpmn (10.7 KB)

Assuming you start the upper process, it will result in an instance of the lower one being created. Once the lower one reaches its end event and sends a message back to the upper process instance, the lower instance will end. After do something is completed in the upper process, that instance is completed as well.

As for the messages themselves, the throwing message events in both processes are typically implemented by executing a piece of custom java code. What the message exactly is or what’s done with it, is up to you. So for instance with the first message, your implementation could simply be a call to RuntimeService.startProcessInstanceByMessage(“some-message”), to start a new instance of the lower process and passing in some variables.

The message end event could have an implementation that does a message correlation to the upper process, using RuntimeService.createMessageCorrelation(“another-message”).processInstanceVariableEquals()…correlate() . Or, you could use a business key or whatever correlation is appropriate.

Hope that helps somewhat.

1 Like

So I always have to find the receiver (process instance) of the message by my implementation logic? If I have an uncorrelated message from a pool instantiated in parallel do I have to send the message to all (waiting) process instances? Will the message in such a case be cloned to all receivers or will the first receiver wins and all other will not get the message?

In most cases, you want to target (correlate) a specific process instance, indeed. If you need to find all of them that match some criteria, or even just all of them that are waiting for a particular message, you can use RuntimeService.createMessageCorrelation(“the-message”).[any other criteria here, or none].correlateAll()

1 Like