Каков наилучший способ проверить следующее условие: Учитывая, что pid ожидает отдельное промежуточное сообщение.Activiti: как проверить, ожидает ли текущий экземпляр процесса на заданном промежуточном событии сообщения
Некоторые вещи, которые я пробовал:
Execution execution = runtimeService.createExecutionQuery().processInstanceId(<pId>)
.activityId(<messageEventName>).singleResult();
if(null!=execution){
//I have got assurance that this pId is pending with this messageEventName currently
}
Мой bmp.xml код промежуточного события сообщения:
<intermediateCatchEvent id="messageintermediatecatchevent1" name="MessageCatchEvent">
<messageEventDefinition messageRef="actionOnPendingLR"></messageEventDefinition>
</intermediateCatchEvent>
Мои Java-код:
private Execution checkIfProcessPendingOnPendingLRMessage(UserAction request) throws Exception {
String pId = request.getProcessInstanceId();
Execution execution = null;
String messageName = "messageintermediatecatchevent1";
try {
execution = runtimeService.createExecutionQuery().processInstanceId(pId)
.activityId(messageName).singleResult();
} catch (Exception exe) {
logger.error("supplied process instance is not matching on the state in which it is pending" + pId, exe);
}
if (execution == null) {
throw new RuntimeException(
"Couldn't find waiting process instance with id '" + pId + "' for message '" + messageName + "'");
}
return execution;
}
& & проверки
(null!=checkIfProcessPendingOnPendingLRMessage(request)) //in main method.
Может кто-нибудь подтвердить, что это правильный код/способ достижения моей цели. Кроме того, пожалуйста, поделитесь правильным подходом.