Instead of having a gateway with N outgoing branches, I would like to delegate the work to subprocesses based on some input variable. For example, if my input_var="message_A", then the subprocess subscribing to message_A is started, then, once it is finished, it goes back to the main process, passing some variables generated in the subprocess to the main process. See the screenshot below:
Doing the above doesn’t work as I have the following error:
The process could not be started.: Cannot instantiate process definition master:1:f75a21cf-0f9e-11ea-89b8-50eb7136ed6c: Error while evaluating expression: ${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“message_A”).correlateWithResult()}. Cause: org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘message_A’: No process definition or execution matches the parameters
Any idea why it doesn’t work? It this even a good approach? Thanks a lot for your upcoming feedbacks.
The BPMN standard doesn’t let you send a message that does not leave the scope of the process which creates it. Which is probably for the best because you should probably be using a conditional event rather than a message event, it’ll do what you want with a lot less effort.
Thanks @Niall for the reply, so, in general, the best way to replace a gateway with N outgoing branches (a bit ugly I suppose) is then to use a conditionnal event subprocess. Variables created in that subprocess will be sent back to the main process right ?
The reason is that each subprocess is associated to a specific decision table. The decision tables are very specific and depend on a variable defined in the main process (different types of json objects and 1 json object = 1 table). The keys in my json object might change and I need to adapt my tables in consequence. The thing is that I’ll probably need to deal with dozen of json objects (i.e dozen of decision tables), having subprocesses instead of multiple branches is probably more human readable.
In other words, using a scripting philosophy, I just want to call different functions based on the input variable value (the functions being the subprocesses in this analogy). y=f(x=a) or y=g(x=b)
I would love to do it this way, but I’m still a unexperienced camunda user and an example would greatly help. What do you mean by calling a DMN table dynamically?
Thanks a lot @Niall and @JarlSeverin, it works like a charm, I made the decision based on my variable, I guess it’s not quite the answer to my original questions but it serves very well my purpose. Hope it can help someone else. Here an example of what I’m using right now: