Using MessageCorrelationBuilder (https://docs.camunda.org/javadoc/camunda-bpm-platform/7.7/org/camunda/bpm/engine/runtime/MessageCorrelationBuilder.html#correlateWithResult()) or some other way through the Java API, is there a way to preform message correlation to only the latest version of a process definition and with all versions of a process definition?
Message Correlation: Is it possible to correlate with latest version of Process Definition or with all versions of Process Definition?
what kind of message event do you want to correlate to?
You can use the Message Api to correlate to a message start event, using:
runtimeService .createMessageCorrelation("messageName") .correlateStartMessage();
This correlates the message event only to the latest version of a process definition.
If you want to correlate the message to a specific version then you must use the process definition id of the version.
runtimeService .createMessageCorrelation("messageName") .processDefinitionId("id") .correlateStartMessage();
Does this help you?
@Philipp_Ossler on 7.6 this does not appear to be the behaviour i am seeing.
... var correlation = execution.getProcessEngineServices() .getRuntimeService() .createMessageCorrelation('response_' + myIdVar) .setVariable('...', ...) .setVariable('...', ...) .setVariable('...', ...) .correlateWithResult(); ...
When this executes, I have a another process that is waiting, but there are two instances (in different process def versions) waiting for that message.
the above code gets the following result:
org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name 'response_181' to a single execution. 2 executions match the correlation keys: CorrelationSet [businessKey=null, processInstanceId=null, processDefinitionId=null, correlationKeys=null, tenantId=null, isTenantIdSet=false]
There is only one process instance in the latest process def version that is waiting for this message.
Based on your description, this should not be occurring.
@StephenOTT, do you want to correlate the message to a message start event or an intermediate message event?
In your example, the engine tries to correlate the message to all running executions + message start event of the latest version. If you want to correlate only the executions of the latest version then you have to use other correlation keys or resolve the execution ids manually. Please have a look at the reference guide.
@Philipp_Ossler, just curious on background reasons: is there any specifics on why only Deff IDs were supported any nothing like a Deff Key which defaults to the latest definition (similar to show Start instance functions)