in fireUntilHalt for salience to take effect the rules must be in conflict; i.e. on the agenda at the same time, normally due to activation being created from the same working memory action.
If you insert message and later insert person, the message will react straight away and fire; as there is nothing cuasing it to wait to become in conflict with other rules. Try adding an "exists Person()" pattern to rule1b. Mark On 13/07/2012 18:37, Ladd wrote: > I'm using drools-camel 5.4.0.Final. ksession is stateful, I'm in STREAM > mode, and rules are fired with fireUntilHalt(). > > My test route is: > > from( "direct:test-message" ).to( > "drools://node/ksession1?action=insertMessage" ); > > I'm sending my objects into the engine like so: > > template.sendBody( "direct:test-message", new Person( "Bob" ) ); > template.sendBody( "direct:test-message", new Person( "Jim" ) ); > > I have two rules that I'd like to fire in a specific order (1a followed by > 1b). > > If I define rule1a first in my drl it fires first as I would expect (with or > without a salience specified). But if I define rule1b first, that fires > first even though rule1a has a higher salience. > > Here are my two rules / test cases and the results: > > *Scenario 1 (rule1a first first as I want it to):* > > rule += "rule rule1a salience 100 \n"; > rule += " when \n"; > rule += " $m : Message( body.class == Person.class, $body : body ) \n"; > rule += " $p : Person() from $body \n"; > rule += " then \n"; > rule += " System.err.println( \"rule1a: Just found person \" + > $p.getName() ); \n"; > rule += "end\n"; > > rule += "rule rule1b\n"; > rule += " when \n"; > rule += " $m : Message() \n"; > rule += " then \n"; > rule += " System.err.println( \"rule1b: Just found message \" + > $m.getBody().toString() ); \n"; > rule += "end\n"; > > *Output:* > rule1a: Just found person Bob > rule1b: Just found message > org.apache.camel.component.bean.pojomessage.Person@b49448 > rule1a: Just found person Jim > rule1b: Just found message > org.apache.camel.component.bean.pojomessage.Person@f4e9d3 > > *Scenario 2 (rule1b fires first even through rule1a has a higher salience):* > > rule += "rule rule1b\n"; > rule += " when \n"; > rule += " $m : Message() \n"; > rule += " then \n"; > rule += " System.err.println( \"rule1b: Just found message \" + > $m.getBody().toString() ); \n"; > rule += "end\n"; > > rule += "rule rule1a salience 100 \n"; > rule += " when \n"; > rule += " $m : Message( body.class == Person.class, $body : body ) \n"; > rule += " $p : Person() from $body \n"; > rule += " then \n"; > rule += " System.err.println( \"rule1a: Just found person \" + > $p.getName() ); \n"; > rule += "end\n"; > > *Output:* > rule1b: Just found message > org.apache.camel.component.bean.pojomessage.Person@1133fd6 > rule1a: Just found person Bob > rule1b: Just found message > org.apache.camel.component.bean.pojomessage.Person@ca425c > rule1a: Just found person Jim > > Something simple I'm sure. Any pointers to get my salience working? > > Thanks for taking the time to help me out!! > > - Ladd > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users