*
* @see <a href="http://www.activiti.org/userguide/index.html#bpmnSignalEventDefinition" />
* @see CoreSignals
*/
protected void triggerSignalEvent(ProcessEngine processEngine, String businessKey, String signalName) {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceBusinessKey(businessKey).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getProcessInstanceId())
.signalEventSubscriptionName(signalName).list();
if (executions.isEmpty()) {
throw new NoSuchElementException(String.format("No executions found waiting " +
"for signal '%s' on process %s", signalName, businessKey));
}
for (Execution execution : executions) {
LOG.info("Sending '{}' signal to execution {} for process {}",
new Object[]{signalName, execution.getId(), businessKey});
runtimeService.signalEventReceived(signalName, execution.getId());
}
}