Skip to content

Instantly share code, notes, and snippets.

@berndruecker
Last active March 23, 2017 15:34
Show Gist options
  • Save berndruecker/5e84238e9bc08d86c9bdf50f77683214 to your computer and use it in GitHub Desktop.
Save berndruecker/5e84238e9bc08d86c9bdf50f77683214 to your computer and use it in GitHub Desktop.
public boolean handleEvent(String type, String eventName, String transactionId, JsonObject event) {
VariableMap correlationKeys = getCorrelationKeys(event);
MessageCorrelationBuilder correlation = engine.getRuntimeService().createMessageCorrelation(eventName);
ExecutionQuery query = engine.getRuntimeService().createExecutionQuery().messageEventSubscriptionName(eventName);
for (String key : correlationKeys.keySet()) {
correlation.processInstanceVariableEquals(key, correlationKeys.get(key));
query.processVariableValueEquals(key, correlationKeys.get(key));
}
// we do a query first to check if somebody is waiting, might be that the event is not targeted at our service
if (query.count()==0) {
return false; // not handled
}
// otherwise correlate it add all possible additional correlation keys as variables to the flow
correlation.setVariables(getNewVariables(event));
correlation.correlateWithResult();
return true; // handled
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment