在阅读(https://docs.camunda.org/manual/7.5/user-guide/process-engine/variables/)时,我不确定您如何检索变量?
目前,我正在努力找出如何访问先前设置的流程变量。我尝试的是:
我有一个简单的 bpmn 进程,其中我有启动事件、1 个服务任务和结束事件,我通过传递 2 个变量(a&b)来启动我的进程,并且我的服务任务正在实现以下 java 类:
public class Addition implements JavaDelegate {
public void execute(DelegateExecution exe) throws Exception {
System.out.println("Inside calculator again");
Integer x = (Integer) exe.getVariable("a");
Integer y = (Integer) exe.getVariable("b");
int add = x+y;
System.out.println("Addition of two number is"+add);
exe.setVariable("add",add);
}
我开始我的过程如下:
public void sayHello(ProcessEngine processEngine)
{
Map<String,Object> variables = new HashMap<String, Object>();
variables.put("a", 3);
variables.put("b", 5);
ProcessInstance instance= processEngine.getRuntimeService().startProcessInstanceByKey("Process_3", variables);
}
我想访问add
sayHello 类中的变量(存在于 Addition 类中)?由于流程已经完成,所以我无法使用 runtimeService,所以我尝试使用历史服务,但找不到任何解决方案。
有没有我可以使用的 Java API 或者有其他方法吗?