public class MessageCorrelationBuilderImpl extends Object implements MessageCorrelationBuilder
Modifier and Type | Field and Description |
---|---|
protected String |
businessKey |
protected CommandContext |
commandContext |
protected CommandExecutor |
commandExecutor |
protected org.camunda.bpm.engine.variable.VariableMap |
correlationLocalVariables |
protected org.camunda.bpm.engine.variable.VariableMap |
correlationProcessInstanceVariables |
protected boolean |
isExclusiveCorrelation |
protected boolean |
isTenantIdSet |
protected String |
messageName |
protected org.camunda.bpm.engine.variable.VariableMap |
payloadProcessInstanceVariables |
protected org.camunda.bpm.engine.variable.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() |
org.camunda.bpm.engine.variable.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 org.camunda.bpm.engine.variable.VariableMap correlationProcessInstanceVariables
protected org.camunda.bpm.engine.variable.VariableMap correlationLocalVariables
protected org.camunda.bpm.engine.variable.VariableMap payloadProcessInstanceVariables
protected org.camunda.bpm.engine.variable.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)
MessageCorrelationBuilder
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.
processInstanceBusinessKey
in interface MessageCorrelationBuilder
businessKey
- the businessKey to correlate on.public MessageCorrelationBuilder processInstanceVariableEquals(String variableName, Object variableValue)
MessageCorrelationBuilder
Correlate the message such that the process instance has a variable with the given name and value.
processInstanceVariableEquals
in interface MessageCorrelationBuilder
variableName
- 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)
MessageCorrelationBuilder
Correlate the message such that the process instance has the given variables.
processInstanceVariablesEqual
in interface MessageCorrelationBuilder
variables
- the variables of the process instance to correlate on.public MessageCorrelationBuilder localVariableEquals(String variableName, Object variableValue)
MessageCorrelationBuilder
Correlate the message such that the execution has a local variable with the given name and value.
localVariableEquals
in interface MessageCorrelationBuilder
variableName
- 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)
MessageCorrelationBuilder
Correlate the message such that the execution has the given variables as local variables.
localVariablesEqual
in interface MessageCorrelationBuilder
variables
- the local variables of the execution to correlate on.protected void ensureCorrelationProcessInstanceVariablesInitialized()
protected void ensureCorrelationLocalVariablesInitialized()
public MessageCorrelationBuilder processInstanceId(String id)
MessageCorrelationBuilder
Correlate the message such that a process instance with the given id is selected.
processInstanceId
in interface MessageCorrelationBuilder
id
- the id of the process instance to correlate on.public MessageCorrelationBuilder processDefinitionId(String processDefinitionId)
MessageCorrelationBuilder
Correlate 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 MessageCorrelationBuilder
processDefinitionId
- the id of the process definition to correlate on.public MessageCorrelationBuilder setVariable(String variableName, Object variableValue)
MessageCorrelationBuilder
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.
setVariable
in interface MessageCorrelationBuilder
variableName
- the name of the variable to setvariableValue
- the value of the variable to setpublic MessageCorrelationBuilder setVariableLocal(String variableName, Object variableValue)
MessageCorrelationBuilder
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.
setVariableLocal
in interface MessageCorrelationBuilder
variableName
- the name of the variable to setvariableValue
- the value of the variable to setpublic MessageCorrelationBuilder setVariables(Map<String,Object> variables)
MessageCorrelationBuilder
Pass a map of variables to the execution waiting on the message. Use this method for passing the message's payload
setVariables
in interface MessageCorrelationBuilder
variables
- the map of variablespublic MessageCorrelationBuilder setVariablesLocal(Map<String,Object> variables)
MessageCorrelationBuilder
Pass a map of local variables to the execution waiting on the message. Use this method for passing the message's payload
setVariablesLocal
in interface MessageCorrelationBuilder
variables
- the map of local variablesprotected void ensurePayloadProcessInstanceVariablesInitialized()
protected void ensurePayloadProcessInstanceVariablesLocalInitialized()
public MessageCorrelationBuilder tenantId(String tenantId)
MessageCorrelationBuilder
MessageCorrelationBuilder.processInstanceId(String)
or MessageCorrelationBuilder.processDefinitionId(String)
.tenantId
in interface MessageCorrelationBuilder
tenantId
- the id of the tenantpublic MessageCorrelationBuilder withoutTenantId()
MessageCorrelationBuilder
MessageCorrelationBuilder.processInstanceId(String)
or MessageCorrelationBuilder.processDefinitionId(String)
.withoutTenantId
in interface MessageCorrelationBuilder
public MessageCorrelationBuilder startMessageOnly()
MessageCorrelationBuilder
startMessageOnly
in interface MessageCorrelationBuilder
public void correlate()
MessageCorrelationBuilder
correlate
in interface MessageCorrelationBuilder
#correlateWithResult()}
public MessageCorrelationResult correlateWithResult()
MessageCorrelationBuilder
MessageCorrelationResult
object.
The call of this method will result in either:
MessageCorrelationResult.getResultType()
.correlateWithResult
in interface MessageCorrelationBuilder
public MessageCorrelationResultWithVariables correlateWithResultAndVariables(boolean deserializeValues)
MessageCorrelationBuilder
MessageCorrelationBuilder.correlateWithResult()
to avoid unnecessary variable access.correlateWithResultAndVariables
in interface MessageCorrelationBuilder
deserializeValues
- if false, returned SerializableValue
s
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 MessageCorrelationBuilder
public void correlateAll()
MessageCorrelationBuilder
correlateAll
in interface MessageCorrelationBuilder
#correlateAllWithResult()}
public List<MessageCorrelationResult> correlateAllWithResult()
MessageCorrelationBuilder
This 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 MessageCorrelationBuilder
public List<MessageCorrelationResultWithVariables> correlateAllWithResultAndVariables(boolean deserializeValues)
MessageCorrelationBuilder
MessageCorrelationBuilder.correlateAllWithResult()
to avoid unnecessary variable access.correlateAllWithResultAndVariables
in interface MessageCorrelationBuilder
deserializeValues
- if false, returned SerializableValue
s
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()
MessageCorrelationBuilder
This will result in either:
correlateStartMessage
in interface MessageCorrelationBuilder
protected 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 org.camunda.bpm.engine.variable.VariableMap getPayloadProcessInstanceVariablesLocal()
public boolean isExclusiveCorrelation()
public String getTenantId()
public boolean isTenantIdSet()
Copyright © 2022. All rights reserved.