jbpm網關和線Sequence Flow的用法總結

  • 並行網關:Parallel Gateway(一入多出 gatewayDirection="Diverging")會執行全部的路徑,此時不要在路徑上設置條件,由於條件不會生效
  • 條件網關:Inclusive Gateway(一入多出 gatewayDirection="Diverging")只有路徑上的條件是true的時候纔會繼續執行
  • 聚合網關:Inclusive Gateway(多入一出 gatewayDirection="Converging")等待多個全部的路徑都執行完畢纔會繼續向下執行

Note:全部類型的網關不能夠同時擁有多個入口和多個出口
filejava

關於Sequence Flow也就是圖中的線,當鏈接的是並行網關的時候是無法加condition的,condition必需要有一個true或false的返回的值,以下面的例子,使用java代碼寫的condition(紅色部分),注意必需要return。express

<sequenceFlowid="SequenceFlow_053b7wt"name="java腳本線"sourceRef="ExclusiveGateway_1wgfzzs"
targetRef="business">
<conditionExpression xsi:type="tFormalExpression">System.out.println("條件網關");
return true;
</conditionExpression>
</sequenceFlow>

<sequenceFlowid="SequenceFlow_0fjx8rl"name="表達式線"sourceRef="ExclusiveGateway_1wgfzzs"
targetRef="Task_014lbgb">
<conditionExpressionxsi:type="tFormalExpression">2&gt;1</conditionExpression>
</sequenceFlow>

觸發指定agenda-group的規則和ruleflow-group的規則segmentfault

kieSession.getAgenda().getAgendaGroup("test").setFocus();
((InternalAgenda)kieSession.getAgenda()).activateRuleFlowGroup("test");

在jbpm中的condition expresss使用MVEL、java和表達式,最主要的是language那裏的區別
DRL語言this

<conditionExpression xsi:type="tFormalExpression"language="http://www.jboss.org/drools/rule">
com.trusfort.credit.decision.pojo.DecisionFlow(id=="1")
</conditionExpression>

當判斷條件爲map時按照以下寫法:spa

java.util.HashMap(
this["a"]>1
)

java語言code

<conditionExpressionxsi:type="tFormalExpression"
language="http://www.java.com/java">
return ture
</conditionExpression>

表達式orm

<sequenceFlowid="SequenceFlow_0fjx8rl"name="表達式線"sourceRef="ExclusiveGateway_1wgfzzs"
targetRef="Task_014lbgb">
<conditionExpressionxsi:type="tFormalExpression">2&gt;1</conditionExpression>
</sequenceFlow>

若是網關是parallel gateway(並行網關)時 線上的條件是無效的,Inclusive gateway 和exclusive gateway 線上的條件是有效的blog

相關文章
相關標籤/搜索