Correlate a Message

Correlates a message to the process engine to either trigger a message start event or an intermediate message catching event. Internally this maps to the engine’s message correlation builder methods MessageCorrelationBuilder#correlateWithResult() and MessageCorrelationBuilder#correlateAllWithResult(). For more information about the correlation behavior, see the Message Events section of the BPMN 2.0 Implementation Reference.

Method

POST /message

Parameters

Request Body

A JSON object with the following properties:

Name Description
messageName The name of the message to deliver.
businessKey Used for correlation of process instances that wait for incoming messages. Will only correlate to executions that belong to a process instance with the provided business key.
tenantId Used to correlate the message for a tenant with the given id. Will only correlate to executions and process definitions which belong to the tenant.
withoutTenantId A Boolean value that indicates whether the message should only be correlated to executions and process definitions which belong to no tenant or not. Value may only be true, as false is the default behavior.
processInstanceId Used to correlate the message to the process instance with the given id. Must not be supplied in conjunction with a tenantId.
correlationKeys Used for correlation of process instances that wait for incoming messages. Has to be a JSON object containing key-value pairs that are matched against process instance variables during correlation. Each key is a variable name and each value a JSON variable value object with the following properties.
Name Description
value The variable's value.
type The value type of the variable. Valid types are String, Integer, Short, Long, Double and Date.

Note: Process instance variables are the global variables of a process instance. Local variables of child executions (such as in subprocesses) are not considered!

processVariables A map of variables that is injected into the triggered execution or process instance after the message has been delivered. Each key is a variable name and each value a JSON variable value object with the following properties.

Name Description
value The variable's value. For variables of type Object, the serialized value has to be submitted as a String value.

For variables of type File the value has to be submitted as Base64 encoded string.

type The value type of the variable.
valueInfo A JSON object containing additional, value-type-dependent properties.

For serialized variables of type Object, the following properties can be provided:

  • objectTypeName: A string representation of the object's type name.
  • serializationDataFormat: The serialization format used to store the variable.

For serialized variables of type File, the following properties can be provided:

  • filename: The name of the file. This is not the variable name but the name that will be used when downloading the file again.
  • mimetype: The MIME type of the file that is being uploaded.
  • encoding: The encoding of the file that is being uploaded.

all A Boolean value that indicates whether the message should be correlated to exactly one entity or multiple entities. If the value is set to false, the message will be correlated to exactly one entity (execution or process definition). If the value is set to true, the message will be correlated to multiple executions and a process definition that can be instantiated by this message in one go.
resultEnabled A Boolean value that indicates whether the result of the correlation should be returned or not. If this property is set to true, there will be returned a list of message correlation result objects. Depending on the all property, there will be either one ore more returned results in the list.

The default value is false, which means no result will be returned.

Result

This method returns no content if the property resultEnabled is set to false, which is the default value. Otherwise, a JSON array of the message correlation results will be returned. Each message correlation result has the following properties:

Name Value Description
resultType String Indicates if the message was correlated to a message start event or an intermediate message catching event. In the first case, the resultType is ProcessDefinition and otherwise Execution.
processInstance Object This property only has a value if the resultType is set to ProcessDefinition. The processInstance with the properties as described in the get single instance method.
execution Object This property only has a value if the resultType is set to Execution. The execution with the properties as described in the get single execution method.

Response Codes

Code Media type Description
200 application/json Request successful. The property resultEnabled in the request body was true.
204 Request successful. The property resultEnabled in the request body was false (Default).
400 application/json If no messageName was supplied. If both tenantId and withoutTenantId are supplied.
If the message has not been correlated to exactly one entity (execution or process definition), or the variable value or type is invalid, for example if the value could not be parsed to an Integer value or the passed variable type is not supported. See the Introduction for the error response format.

Example

Request

POST /message

Request Body:

Variant 1:

{
  "messageName" : "aMessage",
  "businessKey" : "aBusinessKey",
  "correlationKeys" : {
    "aVariable" : {"value" : "aValue", "type": "String"}
  },
  "processVariables" : {
    "aVariable" : {"value" : "aNewValue", "type": "String"},
    "anotherVariable" : {"value" : true, "type": "Boolean"}
  }
}

Variant 2:

{
  "messageName" : "aMessage",
  "businessKey" : "aBusinessKey",
  "correlationKeys" : {
    "aVariable" : {"value" : "aValue", "type": "String"}
  },
  "processVariables" : {
    "aVariable" : {"value" : "aNewValue", "type": "String"},
    "anotherVariable" : {"value" : true, "type": "Boolean"}
  },
  "resultEnabled" : true
}

Response

Variant 1:

Status 204. No content.

Variant 2:

[{
"resultType": "ProcessDefinition",
"execution": null,
"processInstance": {
    "links": [],
    "id": "aProcInstId",
    "definitionId": "aProcDefId",
    "businessKey": "aKey",
    "caseInstanceId": "aCaseInstId",
    "ended": false,
    "suspended": false,
    "tenantId": "aTenantId"
}
}]

On this Page: