public class MessageCorrelationBuilderImpl extends Object implements MessageCorrelationBuilder
| Modifier and Type | Field and Description |
|---|---|
protected String |
businessKey |
protected CommandContext |
commandContext |
protected CommandExecutor |
commandExecutor |
protected VariableMap |
correlationLocalVariables |
protected VariableMap |
correlationProcessInstanceVariables |
protected boolean |
isExclusiveCorrelation |
protected boolean |
isTenantIdSet |
protected String |
messageName |
protected VariableMap |
payloadProcessInstanceVariables |
protected VariableMap |
payloadProcessInstanceVariablesLocal |
protected String |
processDefinitionId |
protected String |
processInstanceId |
protected boolean |
startMessagesOnly |
protected String |
tenantId |
| Constructor and Description |
|---|
MessageCorrelationBuilderImpl(CommandContext commandContext,
String messageName) |
MessageCorrelationBuilderImpl(CommandExecutor commandExecutor,
String messageName) |
| Modifier and Type | Method and Description |
|---|---|
void |
correlate()
Executes the message correlation.
|
void |
correlateAll()
Executes the message correlation for multiple messages.
|
List<MessageCorrelationResult> |
correlateAllWithResult()
Executes the message correlation for multiple messages and returns a list of message correlation results.
|
List<MessageCorrelationResultWithVariables> |
correlateAllWithResultAndVariables(boolean deserializeValues)
Executes the message correlation.
|
void |
correlateExclusively()
Behaves like
MessageCorrelationBuilder.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 reached |
ProcessInstance |
correlateStartMessage()
Executes the message correlation.
|
MessageCorrelationResult |
correlateWithResult()
Executes the message correlation and returns a
MessageCorrelationResult object. |
MessageCorrelationResultWithVariables |
correlateWithResultAndVariables(boolean deserializeValues)
Executes the message correlation.
|
protected void |
ensureCorrelationLocalVariablesInitialized() |
protected void |
ensureCorrelationProcessInstanceVariablesInitialized() |
protected void |
ensureCorrelationVariablesNotSet() |
protected void |
ensurePayloadProcessInstanceVariablesInitialized() |
protected void |
ensurePayloadProcessInstanceVariablesLocalInitialized() |
protected void |
ensureProcessDefinitionAndTenantIdNotSet() |
protected void |
ensureProcessDefinitionIdNotSet() |
protected void |
ensureProcessInstanceAndTenantIdNotSet() |
protected <T> T |
execute(Command<T> command) |
String |
getBusinessKey() |
CommandContext |
getCommandContext() |
CommandExecutor |
getCommandExecutor() |
Map<String,Object> |
getCorrelationLocalVariables() |
Map<String,Object> |
getCorrelationProcessInstanceVariables() |
String |
getMessageName() |
Map<String,Object> |
getPayloadProcessInstanceVariables() |
VariableMap |
getPayloadProcessInstanceVariablesLocal() |
String |
getProcessDefinitionId() |
String |
getProcessInstanceId() |
String |
getTenantId() |
boolean |
isExclusiveCorrelation() |
boolean |
isTenantIdSet() |
MessageCorrelationBuilder |
localVariableEquals(String variableName,
Object variableValue)
Correlate the message such that the execution has a local variable with the given name and value.
|
MessageCorrelationBuilder |
localVariablesEqual(Map<String,Object> variables)
Correlate the message such that the execution has the given variables as local variables.
|
MessageCorrelationBuilder |
processDefinitionId(String processDefinitionId)
Correlate the message such that a process definition with the given id is selected.
|
MessageCorrelationBuilder |
processInstanceBusinessKey(String businessKey)
Correlate the message such that the process instance has a business key with
the given name.
|
MessageCorrelationBuilder |
processInstanceId(String id)
Correlate the message such that a process instance with the given id is selected.
|
MessageCorrelationBuilder |
processInstanceVariableEquals(String variableName,
Object variableValue)
Correlate the message such that the process instance has a
variable with the given name and value.
|
MessageCorrelationBuilder |
processInstanceVariablesEqual(Map<String,Object> variables)
Correlate the message such that the process instance has the given variables.
|
MessageCorrelationBuilder |
setVariable(String variableName,
Object variableValue)
Pass a variable to the execution waiting on the message.
|
MessageCorrelationBuilder |
setVariableLocal(String variableName,
Object variableValue)
Pass a local variable to the execution waiting on the message.
|
MessageCorrelationBuilder |
setVariables(Map<String,Object> variables)
Pass a map of variables to the execution waiting on the message.
|
MessageCorrelationBuilder |
setVariablesLocal(Map<String,Object> variables)
Pass a map of local variables to the execution waiting on the message.
|
MessageCorrelationBuilder |
startMessageOnly()
Specify that only start message can be correlated.
|
MessageCorrelationBuilder |
tenantId(String tenantId)
Specify a tenant to deliver the message to.
|
MessageCorrelationBuilder |
withoutTenantId()
Specify that the message can only be received on executions or process
definitions which belongs to no tenant.
|
protected CommandExecutor commandExecutor
protected CommandContext commandContext
protected boolean isExclusiveCorrelation
protected String messageName
protected String businessKey
protected String processInstanceId
protected String processDefinitionId
protected VariableMap correlationProcessInstanceVariables
protected VariableMap correlationLocalVariables
protected VariableMap payloadProcessInstanceVariables
protected VariableMap payloadProcessInstanceVariablesLocal
protected String tenantId
protected boolean isTenantIdSet
protected boolean startMessagesOnly
public MessageCorrelationBuilderImpl(CommandExecutor commandExecutor, String messageName)
public MessageCorrelationBuilderImpl(CommandContext commandContext, String messageName)
public MessageCorrelationBuilder processInstanceBusinessKey(String businessKey)
MessageCorrelationBuilderCorrelate 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.
processInstanceBusinessKey in interface MessageCorrelationBuilderbusinessKey - the businessKey to correlate on.public MessageCorrelationBuilder processInstanceVariableEquals(String variableName, Object variableValue)
MessageCorrelationBuilderCorrelate the message such that the process instance has a variable with the given name and value.
processInstanceVariableEquals in interface MessageCorrelationBuildervariableName - the name of the process instance variable to correlate on.variableValue - the value of the process instance variable to correlate on.public MessageCorrelationBuilder processInstanceVariablesEqual(Map<String,Object> variables)
MessageCorrelationBuilderCorrelate the message such that the process instance has the given variables.
processInstanceVariablesEqual in interface MessageCorrelationBuildervariables - the variables of the process instance to correlate on.public MessageCorrelationBuilder localVariableEquals(String variableName, Object variableValue)
MessageCorrelationBuilderCorrelate the message such that the execution has a local variable with the given name and value.
localVariableEquals in interface MessageCorrelationBuildervariableName - the name of the local variable to correlate on.variableValue - the value of the local variable to correlate on.public MessageCorrelationBuilder localVariablesEqual(Map<String,Object> variables)
MessageCorrelationBuilderCorrelate the message such that the execution has the given variables as local variables.
localVariablesEqual in interface MessageCorrelationBuildervariables - the local variables of the execution to correlate on.protected void ensureCorrelationProcessInstanceVariablesInitialized()
protected void ensureCorrelationLocalVariablesInitialized()
public MessageCorrelationBuilder processInstanceId(String id)
MessageCorrelationBuilderCorrelate the message such that a process instance with the given id is selected.
processInstanceId in interface MessageCorrelationBuilderid - the id of the process instance to correlate on.public MessageCorrelationBuilder processDefinitionId(String processDefinitionId)
MessageCorrelationBuilderCorrelate the message such that a process definition with the given id is selected.
Is only supported for MessageCorrelationBuilder.correlateStartMessage() or MessageCorrelationBuilder.startMessageOnly() flag.
processDefinitionId in interface MessageCorrelationBuilderprocessDefinitionId - the id of the process definition to correlate on.public MessageCorrelationBuilder setVariable(String variableName, Object variableValue)
MessageCorrelationBuilderPass 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.
setVariable in interface MessageCorrelationBuildervariableName - the name of the variable to setvariableValue - the value of the variable to setpublic MessageCorrelationBuilder setVariableLocal(String variableName, Object variableValue)
MessageCorrelationBuilderPass 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.
setVariableLocal in interface MessageCorrelationBuildervariableName - the name of the variable to setvariableValue - the value of the variable to setpublic MessageCorrelationBuilder setVariables(Map<String,Object> variables)
MessageCorrelationBuilderPass a map of variables to the execution waiting on the message. Use this method for passing the message's payload
setVariables in interface MessageCorrelationBuildervariables - the map of variablespublic MessageCorrelationBuilder setVariablesLocal(Map<String,Object> variables)
MessageCorrelationBuilderPass a map of local variables to the execution waiting on the message. Use this method for passing the message's payload
setVariablesLocal in interface MessageCorrelationBuildervariables - the map of local variablesprotected void ensurePayloadProcessInstanceVariablesInitialized()
protected void ensurePayloadProcessInstanceVariablesLocalInitialized()
public MessageCorrelationBuilder tenantId(String tenantId)
MessageCorrelationBuilderMessageCorrelationBuilder.processInstanceId(String) or MessageCorrelationBuilder.processDefinitionId(String).tenantId in interface MessageCorrelationBuildertenantId - the id of the tenantpublic MessageCorrelationBuilder withoutTenantId()
MessageCorrelationBuilderMessageCorrelationBuilder.processInstanceId(String) or MessageCorrelationBuilder.processDefinitionId(String).withoutTenantId in interface MessageCorrelationBuilderpublic MessageCorrelationBuilder startMessageOnly()
MessageCorrelationBuilderstartMessageOnly in interface MessageCorrelationBuilderpublic void correlate()
MessageCorrelationBuildercorrelate in interface MessageCorrelationBuilder#correlateWithResult()}public MessageCorrelationResult correlateWithResult()
MessageCorrelationBuilderMessageCorrelationResult object.
The call of this method will result in either:
MessageCorrelationResult.getResultType().correlateWithResult in interface MessageCorrelationBuilderpublic MessageCorrelationResultWithVariables correlateWithResultAndVariables(boolean deserializeValues)
MessageCorrelationBuilderMessageCorrelationBuilder.correlateWithResult()
to avoid unnecessary variable access.correlateWithResultAndVariables in interface MessageCorrelationBuilderdeserializeValues - if false, returned SerializableValues
will not be deserialized (unless they are passed into this method as a
deserialized value or if the BPMN process triggers deserialization)#correlateWithResult()}public void correlateExclusively()
MessageCorrelationBuilder
Behaves like MessageCorrelationBuilder.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 reached
CAUTION: 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.
correlateExclusively in interface MessageCorrelationBuilderpublic void correlateAll()
MessageCorrelationBuildercorrelateAll in interface MessageCorrelationBuilder#correlateAllWithResult()}public List<MessageCorrelationResult> correlateAllWithResult()
MessageCorrelationBuilderThis will result in any number of the following:
Note that the message correlates to all tenants if no tenant is specified using MessageCorrelationBuilder.tenantId(String) or MessageCorrelationBuilder.withoutTenantId().
correlateAllWithResult in interface MessageCorrelationBuilderpublic List<MessageCorrelationResultWithVariables> correlateAllWithResultAndVariables(boolean deserializeValues)
MessageCorrelationBuilderMessageCorrelationBuilder.correlateAllWithResult()
to avoid unnecessary variable access.correlateAllWithResultAndVariables in interface MessageCorrelationBuilderdeserializeValues - if false, returned SerializableValues
will not be deserialized (unless they are passed into this method as a
deserialized value or if the BPMN process triggers deserialization)#correlateAllWithResult()}public ProcessInstance correlateStartMessage()
MessageCorrelationBuilderThis will result in either:
correlateStartMessage in interface MessageCorrelationBuilderprotected void ensureProcessDefinitionIdNotSet()
protected void ensureProcessInstanceAndTenantIdNotSet()
protected void ensureCorrelationVariablesNotSet()
protected void ensureProcessDefinitionAndTenantIdNotSet()
protected <T> T execute(Command<T> command)
public CommandExecutor getCommandExecutor()
public CommandContext getCommandContext()
public String getMessageName()
public String getBusinessKey()
public String getProcessInstanceId()
public String getProcessDefinitionId()
public Map<String,Object> getCorrelationProcessInstanceVariables()
public VariableMap getPayloadProcessInstanceVariablesLocal()
public boolean isExclusiveCorrelation()
public String getTenantId()
public boolean isTenantIdSet()
Copyright © 2021. All rights reserved.