Interface MessageCorrelationBuilder
- All Known Implementing Classes:
MessageCorrelationBuilderImpl
A fluent builder for defining message correlation
- Author:
- Daniel Meyer, Christopher Zell
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Executes the message correlation.void
Executes the message correlation for multiple messages.Executes the message correlation for multiple messages and returns a list of message correlation results.correlateAllWithResultAndVariables
(boolean deserializeValues) Executes the message correlation.void
Behaves likecorrelate()
, however uses pessimistic locking for correlating a waiting execution, meaning that two threads correlating a message to the same execution in parallel do not end up continuing the process in parallel until the next wait state is reachedExecutes the message correlation.Executes the message correlation and returns aMessageCorrelationResult
object.correlateWithResultAndVariables
(boolean deserializeValues) Executes the message correlation.localVariableEquals
(String variableName, Object variableValue) Correlate the message such that the execution has a local variable with the given name and value.localVariablesEqual
(Map<String, Object> variables) Correlate the message such that the execution has the given variables as local variables.processDefinitionId
(String processDefinitionId) Correlate the message such that a process definition with the given id is selected.processInstanceBusinessKey
(String businessKey) Correlate the message such that the process instance has a business key with the given name.Correlate the message such that a process instance with the given id is selected.processInstanceVariableEquals
(String variableName, Object variableValue) Correlate the message such that the process instance has a variable with the given name and value.processInstanceVariablesEqual
(Map<String, Object> variables) Correlate the message such that the process instance has the given variables.setVariable
(String variableName, Object variableValue) Pass a variable to the execution waiting on the message.setVariableLocal
(String variableName, Object variableValue) Pass a local variable to the execution waiting on the message.setVariables
(Map<String, Object> variables) Pass a map of variables to the execution waiting on the message.setVariablesLocal
(Map<String, Object> variables) Pass a map of local variables to the execution waiting on the message.Specify that only start message can be correlated.Specify a tenant to deliver the message to.Specify that the message can only be received on executions or process definitions which belongs to no tenant.
-
Method Details
-
processInstanceBusinessKey
Correlate the message such that the process instance has a business key with the given name. If the message is correlated to a message start event then the given business key is set on the created process instance.
- Parameters:
businessKey
- the businessKey to correlate on.- Returns:
- the builder
-
processInstanceVariableEquals
Correlate the message such that the process instance has a variable with the given name and value.
- Parameters:
variableName
- the name of the process instance variable to correlate on.variableValue
- the value of the process instance variable to correlate on.- Returns:
- the builder
-
processInstanceVariablesEqual
Correlate the message such that the process instance has the given variables.
- Parameters:
variables
- the variables of the process instance to correlate on.- Returns:
- the builder
-
localVariableEquals
Correlate the message such that the execution has a local variable with the given name and value.
- Parameters:
variableName
- the name of the local variable to correlate on.variableValue
- the value of the local variable to correlate on.- Returns:
- the builder
-
localVariablesEqual
Correlate the message such that the execution has the given variables as local variables.
- Parameters:
variables
- the local variables of the execution to correlate on.- Returns:
- the builder
-
processInstanceId
Correlate the message such that a process instance with the given id is selected.
- Parameters:
id
- the id of the process instance to correlate on.- Returns:
- the builder
-
processDefinitionId
Correlate the message such that a process definition with the given id is selected. Is only supported for
correlateStartMessage()
orstartMessageOnly()
flag.- Parameters:
processDefinitionId
- the id of the process definition to correlate on.- Returns:
- the builder
-
setVariable
Pass a variable to the execution waiting on the message. Use this method for passing the message's payload.
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variableName
- the name of the variable to setvariableValue
- the value of the variable to set- Returns:
- the builder
-
setVariableLocal
Pass a local variable to the execution waiting on the message. Use this method for passing the message's payload.
Invoking this method multiple times allows passing multiple variables.
- Parameters:
variableName
- the name of the variable to setvariableValue
- the value of the variable to set- Returns:
- the builder
-
setVariables
Pass a map of variables to the execution waiting on the message. Use this method for passing the message's payload
- Parameters:
variables
- the map of variables- Returns:
- the builder
-
setVariablesLocal
Pass a map of local variables to the execution waiting on the message. Use this method for passing the message's payload
- Parameters:
variables
- the map of local variables- Returns:
- the builder
-
tenantId
Specify a tenant to deliver the message to. The message can only be received on executions or process definitions which belongs to the given tenant. Cannot be used in combination withprocessInstanceId(String)
orprocessDefinitionId(String)
.- Parameters:
tenantId
- the id of the tenant- Returns:
- the builder
-
withoutTenantId
MessageCorrelationBuilder withoutTenantId()Specify that the message can only be received on executions or process definitions which belongs to no tenant. Cannot be used in combination withprocessInstanceId(String)
orprocessDefinitionId(String)
.- Returns:
- the builder
-
startMessageOnly
MessageCorrelationBuilder startMessageOnly()Specify that only start message can be correlated.- Returns:
- the builder
-
correlate
void correlate()Executes the message correlation. -
correlateWithResult
MessageCorrelationResult correlateWithResult()Executes the message correlation and returns aMessageCorrelationResult
object.The call of this method will result in either:
- Exactly one waiting execution is notified to continue. The notification is performed synchronously. The result contains the execution id.
- Exactly one Process Instance is started in case the message name matches a message start event of a process. The instantiation is performed synchronously. The result contains the start event activity id and process definition.
- MismatchingMessageCorrelationException is thrown. This means that either too many executions / process definitions match the correlation or that no execution and process definition matches the correlation.
MessageCorrelationResult.getResultType()
.- Returns:
- The result of the message correlation. Result contains either the execution id or the start event activity id and the process definition.
- Throws:
MismatchingMessageCorrelationException
- if none or more than one execution or process definition is matched by the correlationAuthorizationException
-- if one execution is matched and the user has no
Permissions.UPDATE
permission onResources.PROCESS_INSTANCE
or noPermissions.UPDATE_INSTANCE
permission onResources.PROCESS_DEFINITION
.- if one process definition is matched and the user has no
Permissions.CREATE
permission onResources.PROCESS_INSTANCE
and noPermissions.CREATE_INSTANCE
permission onResources.PROCESS_DEFINITION
.- if one execution is matched and the user has no
- Since:
- 7.6
-
correlateWithResultAndVariables
Executes the message correlation. If you do not need access to the process variables, usecorrelateWithResult()
to avoid unnecessary variable access.- Parameters:
deserializeValues
- if false, returnedSerializableValue
s will not be deserialized (unless they are passed into this method as a deserialized value or if the BPMN process triggers deserialization)- Returns:
- The result of the message correlation. Result contains either the execution id or the start event activity id, the process definition, and the process variables.
-
correlateExclusively
void correlateExclusively()Behaves like
correlate()
, however uses pessimistic locking for correlating a waiting execution, meaning that two threads correlating a message to the same execution in parallel do not end up continuing the process in parallel until the next wait state is reachedCAUTION: Wherever there are pessimistic locks, there is a potential for deadlocks to occur. This can either happen when multiple messages are correlated in parallel, but also with other race conditions such as a message boundary event on a user task. The process engine is not able to detect such a potential. In consequence, the user of this API should investigate this potential in his/her use case and implement countermeasures if needed.
A less error-prone alternative to this method is to set appropriate async boundaries in the process model such that parallel message correlation is solved by optimistic locking.
-
correlateAll
void correlateAll()Executes the message correlation for multiple messages. -
correlateAllWithResult
List<MessageCorrelationResult> correlateAllWithResult()Executes the message correlation for multiple messages and returns a list of message correlation results.This will result in any number of the following:
- Any number of waiting executions are notified to continue. The notification is performed synchronously. The result list contains the execution ids of the notified executions.
- Any number of process instances are started which have a message start event that matches the message name. The instantiation is performed synchronously. The result list contains the start event activity ids and process definitions from all activities on that the messages was correlated to.
Note that the message correlates to all tenants if no tenant is specified using
tenantId(String)
orwithoutTenantId()
.- Returns:
- The result list of the message correlations. Each result contains either the execution id or the start event activity id and the process definition.
- Throws:
AuthorizationException
-- if at least one execution is matched and the user has no
Permissions.UPDATE
permission onResources.PROCESS_INSTANCE
or noPermissions.UPDATE_INSTANCE
permission onResources.PROCESS_DEFINITION
.- if one process definition is matched and the user has no
Permissions.CREATE
permission onResources.PROCESS_INSTANCE
and noPermissions.CREATE_INSTANCE
permission onResources.PROCESS_DEFINITION
.- if at least one execution is matched and the user has no
- Since:
- 7.6
-
correlateAllWithResultAndVariables
List<MessageCorrelationResultWithVariables> correlateAllWithResultAndVariables(boolean deserializeValues) Executes the message correlation. If you do not need access to the process variables, usecorrelateAllWithResult()
to avoid unnecessary variable access.- Parameters:
deserializeValues
- if false, returnedSerializableValue
s will not be deserialized (unless they are passed into this method as a deserialized value or if the BPMN process triggers deserialization)- Returns:
- The result list of the message correlations. Each result contains either the execution id or the start event activity id, the process definition, and the process variables.
-
correlateStartMessage
ProcessInstance correlateStartMessage()Executes the message correlation.This will result in either:
- Exactly one Process Instance is started in case the message name matches a message start event of a process. The instantiation is performed synchronously.
- MismatchingMessageCorrelationException is thrown. This means that either no process definition or more than one process definition matches the correlation.
- Returns:
- the newly created process instance
- Throws:
MismatchingMessageCorrelationException
- if none or more than one process definition is matched by the correlationAuthorizationException
- if one process definition is matched and the user has noPermissions.CREATE
permission onResources.PROCESS_INSTANCE
and noPermissions.CREATE_INSTANCE
permission onResources.PROCESS_DEFINITION
.
-