Kie workbench 引导决策 table 只执行一个规则

Kie workbench Guided decision table Execute only one Rule

我正在尝试执行用 Kie workbench 编写并与 Kie Exceution 服务器集成的规则,并得到了预期的响应。 但我的要求是只对定义的大规则列表执行一个特定规则。我可以通过哪些可能的方式实现。 我使用了 Activation Group , rule flow group 但没有运气如果有人可以帮助我实现这一目标。

我在 KIE Workbench 中创建了 Guided Decision table。并以这种方式生成源

    package demo.drools_examples;
    //from row number: 1
    rule "Row 1 Rule1"
    dialect "mvel"
    when
        f1 : Account( accountType == "Regular" )
    then
        f1.setBaseAmount( 10.0 );
        f1.setBaseThreshold( 10.0 );
        calculateAmount(f1);
        calculateThreshold(f1);
    end
    //from row number: 2
    rule "Row 2 Rule1"
    dialect "mvel"
    when
        f1 : Account( accountType == "Registered" )
    then
        f1.setBaseAmount( 5.0 );
        f1.setBaseThreshold( 15.0 );
        calculateAmount(f1);
        calculateThreshold(f1);
   end
   //from row number: 3
   rule "Row 3 Rule1"
   dialect "mvel"
   when
        f1 : Account( accountType == "Saving" )
    then
        f1.setBaseAmount( 20.0 );
        f1.setBaseThreshold( 10.0 );
        calculateAmount(f1);
        calculateThreshold(f1);
   end

我如何定义 saliance 、激活组或任何其他策略以仅调用规则 1 而不是调用 fireallRules(1).. 请帮助我

您必须调用 fireAllRules,但有一个转折点:

AgendaFilter af = new SingleRuleFilter( "Row 1 Rule1" );
int nFired = kieSession.fireAllRules( af );

而你只需要这样写:

public class SingleRuleFilter implements AgendaFilter {
    private String name;
    public SingleRuleFilter( String name ){
         this.name = name;
    }
    public boolean accept( Activation activation ){
         return activation.getRule().getName().equals( name );
    }
}