简体   繁体   English

Java Drools - 如何触发两条规则?

[英]Java Drools - How to fire two rules?

I'm new to drools and trying to fire two rules for my requirement.我是流口水的新手,并试图根据我的要求触发两条规则。

Rules: Only one from the below, the first one W rule is firing, how to fire the second rule as well?规则:下面只有一个,第一个W规则触发,第二个规则怎么触发?

W rule:

rule "Send an incoming request to W" salience 1
when
    There is an incoming message
    Not routed yet
then
   Create W Request for Cash
   Route to "WQueue".

F Rule:

rule "Send an incoming request to F"
when
    There is an incoming message
    Not routed yet or Routed to "WQueue"
then
   Create F Request for Cash
   Route to "FQueue".

Consequnce and condition:后果和条件:

For the 2nd rule F Rule I am using the 1st and 3rd conditions from below in the when对于1st条规则F Rule ,我when 3rd

[*][]Not routed yet=$out : Router(hasNotRoutes == true)
[consequence][]Route to {routeNames}\.=modify($out) \{addRoute({routeNames})\};
[*][]Routed to {routeName}=$out : Router(routes contains {routeName})

Define a single condition Not routed or routed to {routeName} ... something like this:定义单个条件Not routed or routed to {routeName} ... 像这样:

[*][]Not routed or routed to {routeName}=$out : Router(hasNotRoutes == true || routes contains {routeName})

Right now you're or-ing $out: Router(hasNotRoutes == true) and $out: Router(routes contains {routeName}) which doesn't work for a variety of syntax-related reasons (the $out assignment is part of both, for example).现在你正在或-ing $out: Router(hasNotRoutes == true)$out: Router(routes contains {routeName})由于各种与语法相关的原因( $out分配是一部分两者,例如)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM