设置或更新JBPM6过程变量的正确方法 [英] Proper way to set or update JBPM6 Process Variables

查看:171
本文介绍了设置或更新JBPM6过程变量的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置过程变量,但低于错误

I am trying to set the process variable but getting below error

java.lang.IllegalStateException: Process instance 10[SampleBusinessProcess] is disconnected.
at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:100)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setVariable(WorkflowProcessInstanceImpl.java:343)

这是我的代码-

ProcessInstance processInstance = runtimeEngine.getKieSession().getProcessInstance(processInstanceId);
((WorkflowProcessInstanceImpl) processInstance).setVariable("myvariable", "myvalue");

请帮助我以最佳方式设置过程变量.

Please help me with the best way to set the process variable.

谢谢.

推荐答案

我无法对上一个答案发表评论,所以我将发布此答案.

I can't comment on the previous answer so I'm posting this answer.

我发现的快速而肮脏的方法(从先前的答案中得到启发)是:

The quick and dirty way I found (inspired from previous answer) is:

public void setProcessInstanceVariables(long processInstanceId, Map<String, Object> variables) {
    kieSession.execute(new SetProcessInstanceVariablesCommand(processInstanceId, variables));
}

非常感谢Kris Verlaenen!

Thanks a lot Kris Verlaenen!

这篇关于设置或更新JBPM6过程变量的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆