什麼是檢查以下條件的最佳方式待定: 由於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.
任何人都可以確認這是正確的代碼/方法來實現我的目標。否則請分享正確的方法。