How to correlate a message to embedded subprocess

Hi,
im having some troubles to correlate a message from one process to embedded subprocess. Let’s assume i have following process:


My start sub message throw event is suposed to start embedded subprocess. I’m corelating messages with my custom delegate:
start%20sub%20prop

delegate class:

@Component
public class MessageCorelator implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception {

    execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("start_sub")
            .processInstanceId(execution.getProcessInstanceId()).correlate();
}
}

however when im starting my process instance, it seems that process is getting stuck on delegate execution:

It seems that my MessageCorelator bean was not even triggered by this. Could you please advise what mistake have i made and how can i start the subprocess by message?

Process model attached:
example.bpmn (7.1 KB)

BR,
Chris

In the BPMN standard it’s not permitted to send a message to the same process instance that initialized the request.

But also - it’s a very heavy way of trying to trigger an event subprocess. You’re probably better of using an conditional event.

What exactly is your use case?

1 Like

My use case requires me to trigger this sub process from many points of main process (and only from main process), therefore i wanted to embed this sub process in main process model as it still represents a single instance business wise. You are correct about conditional events, in normal case i would do so, however due to my use case (many entry points to sub-process) this would require me to have process variables and some logic between them and i would prefer not to introduce any additional logic. Should i still use variables and logic between them or is there a better solution?

I don’t really understand what you mean i’m sorry to say.

But you have 2 other better options
Signal event
Escalation event

I hope the can also solve your problem.

ok i will try to show what i mean on a model:

This is more or less what im trying or archive, my initial idea was to use signals, however since signals are global, therefore they can not be used in my case (i need to notify sub-process just within my process instance). Is there a way use signals within process instance only?

You can create a UUID process variable when each process starts and then use that variable as the signal name.

1 Like

Is that the prefered way? it seems that in case of, let’s say, 1mil+ process instancess we will have 1mil+ different signals and tbh this does not feel right when it’s just a signal to process instance relation. I believe you (and your hawk) are right, and at the end i will probably use this solution. Just one final question: is there some mechanic dedicated for within process instance communication (like a signal but taken into consideration just within process-instance)?

Well just to be clear - i don’t actually think i would pick the solution with signals (although it would work) I think it would be better to use escalation events, because then you wouldn’t need the UUID or worry about bad correlation.

1 Like