Class MessageCorrelationBuilderImpl

    • Field Detail

      • isExclusiveCorrelation

        protected boolean isExclusiveCorrelation
      • messageName

        protected java.lang.String messageName
      • businessKey

        protected java.lang.String businessKey
      • processInstanceId

        protected java.lang.String processInstanceId
      • processDefinitionId

        protected java.lang.String processDefinitionId
      • correlationProcessInstanceVariables

        protected VariableMap correlationProcessInstanceVariables
      • correlationLocalVariables

        protected VariableMap correlationLocalVariables
      • payloadProcessInstanceVariables

        protected VariableMap payloadProcessInstanceVariables
      • payloadProcessInstanceVariablesLocal

        protected VariableMap payloadProcessInstanceVariablesLocal
      • tenantId

        protected java.lang.String tenantId
      • isTenantIdSet

        protected boolean isTenantIdSet
      • startMessagesOnly

        protected boolean startMessagesOnly
      • executionsOnly

        protected boolean executionsOnly
    • Constructor Detail

      • MessageCorrelationBuilderImpl

        public MessageCorrelationBuilderImpl​(CommandExecutor commandExecutor,
                                             java.lang.String messageName)
      • MessageCorrelationBuilderImpl

        public MessageCorrelationBuilderImpl​(CommandContext commandContext,
                                             java.lang.String messageName)
    • Method Detail

      • processInstanceBusinessKey

        public MessageCorrelationBuilder processInstanceBusinessKey​(java.lang.String businessKey)
        Description copied from interface: 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.

        Specified by:
        processInstanceBusinessKey in interface MessageCorrelationBuilder
        Parameters:
        businessKey - the businessKey to correlate on.
        Returns:
        the builder
      • processInstanceVariableEquals

        public MessageCorrelationBuilder processInstanceVariableEquals​(java.lang.String variableName,
                                                                       java.lang.Object variableValue)
        Description copied from interface: MessageCorrelationBuilder

        Correlate the message such that the process instance has a variable with the given name and value.

        Specified by:
        processInstanceVariableEquals in interface MessageCorrelationBuilder
        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
      • localVariableEquals

        public MessageCorrelationBuilder localVariableEquals​(java.lang.String variableName,
                                                             java.lang.Object variableValue)
        Description copied from interface: MessageCorrelationBuilder

        Correlate the message such that the execution has a local variable with the given name and value.

        Specified by:
        localVariableEquals in interface MessageCorrelationBuilder
        Parameters:
        variableName - the name of the local variable to correlate on.
        variableValue - the value of the local variable to correlate on.
        Returns:
        the builder
      • ensureCorrelationProcessInstanceVariablesInitialized

        protected void ensureCorrelationProcessInstanceVariablesInitialized()
      • ensureCorrelationLocalVariablesInitialized

        protected void ensureCorrelationLocalVariablesInitialized()
      • setVariable

        public MessageCorrelationBuilder setVariable​(java.lang.String variableName,
                                                     java.lang.Object variableValue)
        Description copied from interface: 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.

        Specified by:
        setVariable in interface MessageCorrelationBuilder
        Parameters:
        variableName - the name of the variable to set
        variableValue - the value of the variable to set
        Returns:
        the builder
      • setVariableLocal

        public MessageCorrelationBuilder setVariableLocal​(java.lang.String variableName,
                                                          java.lang.Object variableValue)
        Description copied from interface: 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.

        Specified by:
        setVariableLocal in interface MessageCorrelationBuilder
        Parameters:
        variableName - the name of the variable to set
        variableValue - the value of the variable to set
        Returns:
        the builder
      • setVariables

        public MessageCorrelationBuilder setVariables​(java.util.Map<java.lang.String,​java.lang.Object> variables)
        Description copied from interface: MessageCorrelationBuilder

        Pass a map of variables to the execution waiting on the message. Use this method for passing the message's payload

        Specified by:
        setVariables in interface MessageCorrelationBuilder
        Parameters:
        variables - the map of variables
        Returns:
        the builder
      • setVariablesLocal

        public MessageCorrelationBuilder setVariablesLocal​(java.util.Map<java.lang.String,​java.lang.Object> variables)
        Description copied from interface: MessageCorrelationBuilder

        Pass a map of local variables to the execution waiting on the message. Use this method for passing the message's payload

        Specified by:
        setVariablesLocal in interface MessageCorrelationBuilder
        Parameters:
        variables - the map of local variables
        Returns:
        the builder
      • ensurePayloadProcessInstanceVariablesInitialized

        protected void ensurePayloadProcessInstanceVariablesInitialized()
      • ensurePayloadProcessInstanceVariablesLocalInitialized

        protected void ensurePayloadProcessInstanceVariablesLocalInitialized()
      • correlateWithResult

        public MessageCorrelationResult correlateWithResult()
        Description copied from interface: MessageCorrelationBuilder
        Executes the message correlation and returns a MessageCorrelationResult 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.

        The result can be identified by calling the MessageCorrelationResult.getResultType().
        Specified by:
        correlateWithResult in interface MessageCorrelationBuilder
        Returns:
        The result of the message correlation. Result contains either the execution id or the start event activity id and the process definition.
      • correlateExclusively

        public void correlateExclusively()
        Description copied from interface: 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.

        Specified by:
        correlateExclusively in interface MessageCorrelationBuilder
      • correlateAllWithResult

        public java.util.List<MessageCorrelationResult> correlateAllWithResult()
        Description copied from interface: MessageCorrelationBuilder
        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 MessageCorrelationBuilder.tenantId(String) or MessageCorrelationBuilder.withoutTenantId().

        Specified by:
        correlateAllWithResult in interface MessageCorrelationBuilder
        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.
      • correlateStartMessage

        public ProcessInstance correlateStartMessage()
        Description copied from interface: MessageCorrelationBuilder
        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.

        Specified by:
        correlateStartMessage in interface MessageCorrelationBuilder
        Returns:
        the newly created process instance
      • ensureProcessDefinitionIdNotSet

        protected void ensureProcessDefinitionIdNotSet()
      • ensureProcessInstanceAndTenantIdNotSet

        protected void ensureProcessInstanceAndTenantIdNotSet()
      • ensureCorrelationVariablesNotSet

        protected void ensureCorrelationVariablesNotSet()
      • ensureProcessDefinitionAndTenantIdNotSet

        protected void ensureProcessDefinitionAndTenantIdNotSet()
      • execute

        protected <T> T execute​(Command<T> command)
      • getMessageName

        public java.lang.String getMessageName()
      • getBusinessKey

        public java.lang.String getBusinessKey()
      • getProcessInstanceId

        public java.lang.String getProcessInstanceId()
      • getProcessDefinitionId

        public java.lang.String getProcessDefinitionId()
      • getCorrelationProcessInstanceVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getCorrelationProcessInstanceVariables()
      • getCorrelationLocalVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getCorrelationLocalVariables()
      • getPayloadProcessInstanceVariables

        public java.util.Map<java.lang.String,​java.lang.Object> getPayloadProcessInstanceVariables()
      • getPayloadProcessInstanceVariablesLocal

        public VariableMap getPayloadProcessInstanceVariablesLocal()
      • isExclusiveCorrelation

        public boolean isExclusiveCorrelation()
      • getTenantId

        public java.lang.String getTenantId()
      • isTenantIdSet

        public boolean isTenantIdSet()
      • isExecutionsOnly

        public boolean isExecutionsOnly()