【发布时间】:2016-07-12 11:54:50
【问题描述】:
阅读时 (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);
}
我想在sayHello 类中访问add 变量(存在于Addition 类中)?
由于流程已经完成,所以我无法使用 runtimeService,所以我尝试使用历史服务,但找不到任何解决方案。
是否有任何我可以使用的 Java API 或有其他方法?
【问题讨论】: