我创建了两个“Hello World”的过程,得到子节点一个旋转。我遇到了麻烦输出从子返回到主过程。我希望有人可以告诉我什么,我做错了,我找不到为什么我的不行揭示任何文档或例子。

在我的主过程中,我有以下的(注意,我已经剪断页眉,页脚,和位置的X,Y,高度,宽度属性):

 ... snip...

 <header>
   <variables>
     <variable name="name" >
      <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
       <value>World</value>
     </variable>
     <variable name="length" >
       <type name="org.drools.process.core.datatype.impl.type.IntegerDataType" />
       <value>0</value>
     </variable>
   </variables>
 </header>

 ... snip...

 <subProcess id="4" name="SubHello"
             processId="subhello" waitForCompletion="true" >
 <mapping type="in" from="name" to="name" />
 <mapping type="out" from="length" to="length" />
</subProcess>

 ... snip...

这里是简单subhello子流程,这简单地取输入,并打印出来,然后获取输入长度返回回出来:

 ... snip...

 <header>
   <variables>
     <variable name="name" >
      <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
       <value></value>
     </variable>
     <variable name="length" >
       <type name="org.drools.process.core.datatype.impl.type.IntegerDataType" />
       <value></value>
     </variable>
   </variables>
 </header>

 <nodes>
   <start id="1" name="Start" />
   <end id="2" name="End" />
   <actionNode id="3" name="Action" >
       <action type="expression" dialect="mvel" >
System.out.println(name + ", " + length + ", in SubProcess, before");
length = name.length;
System.out.println(length + ", in SubProcess, after");
       </action>
   </actionNode>
 </nodes>

 ... snip...

这是因为每个I如何解释该文档和例子。所需要的变量的声明在两个主进程和子进程,然后只使用输入/输出映射元素的子过程从和到属性设置。

问题是....而name时候传递到没有问题的子进程,试图让length回到主进程失败。在子的length已成功修改。但在退出,length在主过程中没有发生变化。

我在做什么错了?指针和解释大加赞赏。感谢。

有帮助吗?

解决方案

的问题是,你的动作不会改变可变长度。它只是改变了你的行动中的局部变量的长度。改变变量的值,使用kcontext.setVariable( “长度”,name.length());

您也应该更新到最新的Drools 5.1 M1发布,为包括用于进行映射的情况下,子进程是完全同步的问题的修补程序(如在你的例子)。

克里斯Verlaenen

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top