Hello,
sometimes judgeAlgoType has value,but sometimes judgeAlgoType is null ,this lead flow occurs exception : Camunda7 ENGINE-16004 Exception while closing command context: Unknown property used in expression: ${judgeAlgoType==‘是’}. Cause: Cannot resolve identifier ‘judgeAlgoType’ ,here are my code, I just don’t know why,can anyone help me fix this?thanks
package com.sanss.prc.diagtask.handler;
import com.sanss.prc.diagtask.service.SubFlowConclusionService;
import com.sanss.prc.model.diag.BaseDiagConclusion;
import com.sanss.prc.model.diag.DiagRequest;
import com.sanss.prc.model.diag.common.DigitalAssistantConstant;
import com.sanss.prc.model.diag.extension.BaseDiagRequestExtension;
import com.sanss.prc.model.enums.EnumOfDiagResult;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskHandler;
import org.camunda.bpm.client.task.ExternalTaskService;
import org.camunda.bpm.engine.variable.VariableMap;
import org.camunda.bpm.engine.variable.Variables;
import org.springframework.cloud.sleuth.instrument.async.TraceableExecutorService;
import javax.annotation.Resource;
/**
@author huangjinjing
@date 2023/8/14 0014
@desc
*/
public abstract class BaseDiagSubFlowHandler extends BaseHandler implements ExternalTaskHandler {
protected String errMsg = “异常”;
protected String errDetail = “异常”;
protected String interfaceErr = “接口调用失败”;
protected Integer redisTtl = 60 * 60;
@Resource
private SubFlowConclusionService subFlowConclusionService;
protected VariableMap variableMap = Variables.createVariables();
@Resource
protected TraceableExecutorService traceableExecutorService;
/**
真正的业务处理
@param externalTask 外部任务
@param externalTaskService 外部任务执行器
@param diagRequest 诊断请求
@param diagExtension 诊断扩展信息
@return 变量map
*/
public abstract BaseDiagConclusion process(final ExternalTask externalTask, final ExternalTaskService externalTaskService, final DiagRequest diagRequest, final BaseDiagRequestExtension diagExtension);
@Override
public void execute(ExternalTask externalTask, ExternalTaskService externalTaskService) {
traceableExecutorService.execute(() → {
HandlerMetaData handlerMetaData = prepareHandlerMetaData(externalTask);
variableMap.remove(DigitalAssistantConstant.ERR_MSG);
BaseDiagConclusion conclusionSubFlow = process(externalTask, externalTaskService, handlerMetaData.diagRequest, handlerMetaData.diagExtension);
if (conclusionSubFlow.getResult() == EnumOfDiagResult.fail.getCode()) {
conclusionSubFlow.setDiagResult(EnumOfDiagResult.fail.getCode());
}
if (conclusionSubFlow.getResult() == EnumOfDiagResult.ok.getCode()) {
conclusionSubFlow.setDiagResult(EnumOfDiagResult.ok.getCode());
}
subFlowConclusionService.saveSubFlowConclusion(externalTask, handlerMetaData.subflowStartTime, conclusionSubFlow, handlerMetaData.diagRequest, handlerMetaData.diagExtension, variableMap);
if (!variableMap.containsKey(DigitalAssistantConstant.ERR_MSG)) {
externalTaskService.complete(externalTask, variableMap);
}
});
}
}
this is actual topic
@Component
@ExternalTaskSubscription(topicName = “algo-type”)
@Slf4j
public class AlgoTypeHandler extends BaseDiagSubFlowHandler {
@Resource
private AlgoInfoMapper algoInfoMapper;
@Override
public BaseDiagConclusion process(ExternalTask externalTask, ExternalTaskService externalTaskService, DiagRequest diagRequest, BaseDiagRequestExtension diagExtension) {
log.info("算法来源查询:{}", diagRequest.algoId);
DiagConclusionSubFlow subFlow = new DiagConclusionSubFlow();
String algoId = diagRequest.algoId;
AlgoInfo algoInfo = algoInfoMapper.getByAlgoId(diagRequest.algoId);
if (Objects.isNull(algoInfo)) {
subFlow.setConclusionDesc("算法ID为" + diagRequest.algoId + "的信息不存在");
log.info("算法信息不存在 algoId:{}", algoId);
subFlow.setResult(EnumOfDiagResult.fail.getCode());
subFlow.setDiagResult(EnumOfDiagResult.fail.getCode());
variableMap.putValue(DigitalAssistantConstant.ERR_MSG, interfaceErr);
externalTaskService.handleBpmnError(externalTask, errDetail, errMsg);
} else {
String type = algoInfo.getFromSource();
log.info("算法Id:{},来源为:{}",diagRequest.algoId,type);
if (StringUtils.isNotBlank(type) && StringUtils.contains(type,"自研")) {
log.info("算法来源查询自研算法Id:{}",diagRequest.algoId);
subFlow.setConclusionDesc("算法来源为自研");
subFlow.setResult(EnumOfDiagResult.ok.getCode());
subFlow.setDiagResult(EnumOfDiagResult.ok.getCode());
variableMap.put(DigitalAssistantConstant.JUDGE_ALGO_TYPE, "是");
} else {
log.info("算法来源查询算法暂无诊断能力:{}",diagRequest.algoId);
subFlow.setConclusionDesc("算法暂无诊断能力");
subFlow.setResult(EnumOfDiagResult.fail.getCode());
subFlow.setDiagResult(EnumOfDiagResult.fail.getCode());
variableMap.put(DigitalAssistantConstant.JUDGE_ALGO_TYPE, "否");
}
}
log.info("算法来源查询算法Id:{},variableMap:{}",externalTask.getProcessInstanceId(), JacksonUtil.enCode(variableMap));
if (!variableMap.containsKey(DigitalAssistantConstant.JUDGE_ALGO_TYPE)) {
log.info("算法来源查询:{},来源未设置值",diagRequest.algoId);
variableMap.put(DigitalAssistantConstant.JUDGE_ALGO_TYPE, "是");
}
return subFlow;
}
}
here are my logs:
now I found when this exception occurs, this topic will retry to run, after serval times, judgeAlgoType has value, why this will happen?
here is my bpmn file:
ipc-diag.bpmn (97.4 KB)
[/quote]