문제

하위 프로세스 노드에 소용돌이를주기 위해 두 개의 "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...

이것은 내가 문서와 예제를 해석 한 방법에 따른 것입니다. 필요한 변수는 기본 프로세스와 하위 프로세스 모두에서 선언 된 다음 하위 프로세스 내/출력 매핑 요소를 사용하여 속성을 설정하고 속성을 설정하십시오.

문제는 .... name 문제없이 하위 프로세스로 전달되었습니다. length 메인 프로세스로 돌아가서 실패했습니다. 그만큼 length 하위 프로세스에서 성공적으로 수정되었습니다. 그러나 출구에서 length 주요 과정에서는 변하지 않았습니다.

내가 뭘 잘못하고 있죠? 포인터와 설명은 대단히 감사합니다. 감사.

도움이 되었습니까?

해결책

문제는 동작이 길이 변수를 변경하지 않는다는 것입니다. 동작 내부의 로컬 변수 길이를 변경합니다. 변수의 값을 변경하려면 kcontext.setVariable ( "length", name.length ())를 사용하십시오.

또한 하위 프로세스가 완전히 동기식 인 경우 (예 : 예에서와 같이) 최신 Drools 5.1 M1 릴리스로 업데이트해야합니다.

크리스 베를라 넨

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top