Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3044

Need BRMS-586/590 hotfix for Drools 5.1.1 / Salience firing order reversed or not observed on multple fact inserts post index

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 5.1.1.FINAL
    • None
    • Hide

      1) Create a new package using the following DRL file
      2) insert new RequestDataColumn fact with columnName = "COUNTRY" and stringValue = "US"
      3) fireAllRules
      4) examine the value of us_issuer_sw, it will be based on the default. ("N")

      package RequestData

      1. this rule depends on country_no, so it fires on 3nd pass
        rule 'db_table.us_issuer_sw 01'
        activation-group "db_table.us_issuer_sw"
        salience 1000
        dialect "mvel"
        when
        DBColumn (tableName == "db_table", columnName == "country_no", integerValue == 98)
        then
        createDBColumn (drools, "db_table", "us_issuer_sw", DataType.STRING, "Y");

      end

      1. this rule is pre-index and fires on first pass
        rule 'db_table.us_issuer_sw default'
        activation-group "db_table.us_issuer_sw"
        salience 500
        dialect "mvel"
        when

      then
      createDBColumn (drools, "db_table", "us_issuer_sw", DataType.STRING, "N");

      end

      1. this rule depends on country_code, so it fires on 2nd pass
        rule 'db_table.country_no 01'
        activation-group "db_table.country_no"
        dialect "mvel"
        when
        DBColumn (tableName == "db_table", columnName == "country_code", stringValue == "US")
        then
        createDBColumn (drools, "db_table", "country_no", DataType.INTEGER, 98);

      end

      1. this rule is pre-index and fires on first pass
        rule 'db_table.country_code 01'
        activation-group "db_table.country_code"
        dialect "mvel"
        when
        RequestDataColumn (columnName == "COUNTRY", $sv : stringValue == "US")
        then
        createDBColumn (drools, "db_table", "country_code", DataType.STRING, $sv);

      end

      Show
      1) Create a new package using the following DRL file 2) insert new RequestDataColumn fact with columnName = "COUNTRY" and stringValue = "US" 3) fireAllRules 4) examine the value of us_issuer_sw, it will be based on the default. ("N") package RequestData this rule depends on country_no, so it fires on 3nd pass rule 'db_table.us_issuer_sw 01' activation-group "db_table.us_issuer_sw" salience 1000 dialect "mvel" when DBColumn (tableName == "db_table", columnName == "country_no", integerValue == 98) then createDBColumn (drools, "db_table", "us_issuer_sw", DataType.STRING, "Y"); end this rule is pre-index and fires on first pass rule 'db_table.us_issuer_sw default' activation-group "db_table.us_issuer_sw" salience 500 dialect "mvel" when then createDBColumn (drools, "db_table", "us_issuer_sw", DataType.STRING, "N"); end this rule depends on country_code, so it fires on 2nd pass rule 'db_table.country_no 01' activation-group "db_table.country_no" dialect "mvel" when DBColumn (tableName == "db_table", columnName == "country_code", stringValue == "US") then createDBColumn (drools, "db_table", "country_no", DataType.INTEGER, 98); end this rule is pre-index and fires on first pass rule 'db_table.country_code 01' activation-group "db_table.country_code" dialect "mvel" when RequestDataColumn (columnName == "COUNTRY", $sv : stringValue == "US") then createDBColumn (drools, "db_table", "country_code", DataType.STRING, $sv); end

      When executing fireAllRules, all pre-index rules fire adhering to the salience prioritization. If, however, during post-index execution, facts are inserted that are used in the conditions of lower salience rules in the same activation group, the rule will fire, regardless of the fact a higher salience rule has already fired.

      This is further complicated when defining default rules of default salience (though any salience value will suffice so long as the default rule has the lowest salience within the activation group). When no pre-indexed facts are availble for the activation group, the default rule fires. along, with other activation group rules. During execution, a new fact is inserted that provides a hit for a higher salience rule in the same activation group as the default rule which already fired, however, the rule is not fired.

      In effect, pre-indexed facts are processed in descending salience order. whereas post-indexed facts are processed in ascending salience order.

      In all scenarios described, there is not a fire once restriction assigned.

            mproctor@redhat.com Mark Proctor
            apwelsh_jira Armand Welsh (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

              Created:
              Updated:
              Archived: