1

使用 WSO2 BPS 3.6.0 - 是否有(标准)方法来更新已运行实例中的实例变量?

背后的原因是 - 客户端在流程初始化时传递了错误的数据,客户端可能会修复其数据,但流程实例记住了错误的值。

我相信我可能仍然会更新数据库中的数据,但我不希望看到进程管理员弄乱数据库

编辑:我正在使用 BPEL 引擎,我的想法是更新变量不是来自流程设计,而是作为纠正措施(管理控制台?api?)

谢谢你的所有想法。

4

1 回答 1

0

您正在根据客户的请求在流程初始化期间设置实例变量。

根据您的要求,需要为请求检索变量的位置。您可以通过使用执行实体而不是在流程初始化期间设置的实例变量来读取数据来做到这一点。

参考下面的例子:

 public class SampleTask implements JavaDelegate {

     public void execute(DelegateExecution execution) throws Exception {
          String userId = execution.getVariable("userId");
         //perform your logic here
     }
 }

如果您想继续使用实例变量,我建议您在流程执行期间更改实例变量。

 public class SampleTask implements JavaDelegate {

     private String userId;

     public void execute(DelegateExecution execution) throws Exception {
          String newUserId = execution.getVariable("userId");
          setUserId(newUserId);
         //perform your logic here
     }

     public void setUserId(String userId) {
          this.userId = userId;
     }

     public String getUserId() {
          return userId;
     }
 }
于 2016-11-21T18:29:51.763 回答