jBPM、并发执行和流程变量

发布于 2024-07-05 15:22:48 字数 143 浏览 10 评论 0原文

当 jBPM 中的流程分叉为并发路径时,每个路径都会获得自己的流程变量副本,以便它们彼此隔离运行。

但是当路径再次连接时会发生什么? 显然,可能存在冲突的更新。 上下文是否恢复到分叉之前的状态? 我可以选择从单独的轨道复制单个变量吗?

When a process in jBPM forks into concurrent paths, each of these paths gets their own copy of the process variables, so that they run isolated from each other.

But what happens when the paths join again ?
Obviously there could be conflicting updates.
Does the context revert back to the state before the fork?
Can I choose to copy individual variables from the separate tracks?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

漫雪独思 2024-07-12 15:22:48

我认为您必须配置任务的任务控制器。 在某些情况下,以不会导致冲突的方式设置 access 属性就足够了(例如对第一个路径的 read 访问权限和 read,write< /code> 访问第二条路径)。 如果不是这种情况,那么您可以实现自己的 TaskControllerHandler 并使用自定义逻辑实现方法 void SubmitTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token) 。 请参阅:任务控制器

I think that you have to configure the Task Controllers of your tasks. In some cases it is enough to set the access attribute in a way that does not result in conflicts (e.g. read access to the first path and read,write access to the second path). If this is not the case then you can implement your own TaskControllerHandler and implement the method void submitTaskVariables(TaskInstance taskInstance, ContextInstance contextInstance, Token token) with your custom logic. Please see: Task Controllers.

池予 2024-07-12 15:22:48

我尝试了一个小实验:

<fork name="fork1" >
    <transition to="right" />
    <transition to="left" />    
</fork>

<node name="left">
    <event type="node-enter">
        <script>
            <expression >
                left="left";
                shared = left;
            </expression>
            <variable name='left' access='write' />
            <variable name='shared' access='write' />
        </script>
    </event>
    <transition to="join" />
</node>

<node name="right">
    <event type="node-enter">
        <script>
            <expression >
                right="right";
                token.parent.processInstance.contextInstance.setVariable("fromRight", "woot!");
                shared = right;
            </expression>
            <variable name='right' access='write' />
            <variable name='shared' access='write' />
        </script>
    </event>
    <transition to="join" />
</node>

<join name="join" >
    <transition to="done"></transition>
</join>

<end-state name="done"/>

最后我可以访问三个变量:shared、right 和“fromRight”,这些变量是由脚本针对父级显式设置的。

共享变量从右侧分支获取其值,左侧所做的更改似乎消失了。

请注意,转换对我来说实际上并不是异步的,整个实验将在一个事务中运行,这些因素可能会影响结果

I tried a little experiment:

<fork name="fork1" >
    <transition to="right" />
    <transition to="left" />    
</fork>

<node name="left">
    <event type="node-enter">
        <script>
            <expression >
                left="left";
                shared = left;
            </expression>
            <variable name='left' access='write' />
            <variable name='shared' access='write' />
        </script>
    </event>
    <transition to="join" />
</node>

<node name="right">
    <event type="node-enter">
        <script>
            <expression >
                right="right";
                token.parent.processInstance.contextInstance.setVariable("fromRight", "woot!");
                shared = right;
            </expression>
            <variable name='right' access='write' />
            <variable name='shared' access='write' />
        </script>
    </event>
    <transition to="join" />
</node>

<join name="join" >
    <transition to="done"></transition>
</join>

<end-state name="done"/>

At the end I had access to three variables, shared, right and "fromRight" which was set by the script against the parent explicitly.

The shared variable took its value from the right fork, changes made on the left seemed to dissappear.

Note that the transitions aren't actually asynchronous for me, and the whole experiment will have run in one transaction, these factors may affect the outcome

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文