Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("aProcessVariable", "aVariableValue");
runtimeService.correlateMessage(messageName, "aBusinessKey", correlationKeys, processVariables);
Execution correlatedExecution = runtimeService.createExecutionQuery()
.activityId("task").processVariableValueEquals("aProcessVariable", "aVariableValue")
.singleResult();
assertNotNull(correlatedExecution);
ProcessInstance correlatedProcessInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(correlatedExecution.getProcessInstanceId()).singleResult();
assertEquals("aBusinessKey", correlatedProcessInstance.getBusinessKey());
runtimeService.deleteProcessInstance(processInstance.getId(), null);
// fluent builder /////////////////////////////
variables = new HashMap<String, Object>();
variables.put("aKey", "aValue");
processInstance = runtimeService.startProcessInstanceByKey("process", "aBusinessKey", variables);
runtimeService.createMessageCorrelation(messageName)
.processInstanceBusinessKey("aBusinessKey")
.processInstanceVariableEquals("aKey", "aValue")
.setVariable("aProcessVariable", "aVariableValue")
.correlate();
correlatedExecution = runtimeService.createExecutionQuery()
.activityId("task").processVariableValueEquals("aProcessVariable", "aVariableValue")
.singleResult();
assertNotNull(correlatedExecution);
correlatedProcessInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(correlatedExecution.getProcessInstanceId()).singleResult();
assertEquals("aBusinessKey", correlatedProcessInstance.getBusinessKey());
runtimeService.deleteProcessInstance(processInstance.getId(), null);