我对Drools相当新,并且让我了解它。 场景:
规则A输出 - >应该触发规则b,规则c并发送然后获得最终输出等
示例:简化
CountryBean --> { String isdCode ,List<String> tates}
rule "Get States by Country's ISD Code"
no-loop true
when country: Country(isCode=="+1")
then
country.setStates("Kentucky" , "North Carolina"....);
update(country);
StateBean --> {String state,String population}
rule "Get Population of States"
no-loop true
when state: States(state !="", $state=state)
then
if(state=="Kentucky")
state.population("1M");
update(state)
我的解决方案
然后迭代状态并执行状态规则
Country country = new Country("+1");
ksession.insert(country )
ksession.fireAllRules();
List<States> stateList=new ArrayList<States>();
country.getStates().forEach(state-> {
ksession.insert(new State(state));
ksession.fireAllRules();stateList.add(state);
});
我不认为这是正确的做法。我该如何处理这个问题?