Ck,
You need to think different when using forward chaining. Your data will drive the execution, not your "goals".
So, the state of your facts match rule B twice, it will fire twice.
"Stupid" example:
rule "1. increment counter"
salience 10
when
$c : Counter( value < 2 )
then
System.out.println( "firing rule 1" );
$c.setValue( $c.getValue() + 1 );
modify( $c );
end
rule "2. diplay counter"
when
Counter( $value : value )
then
System.out.println("Value = "+$value);
end
If you do:
wm.assertObject( new Counter( 0 ) );
wm.fireAllRules();
Rules will fire:
1 -> 1 -> 2
But that is because your "state" (facts) drive them in that way. Do you understand that? Try removing salience attribute and check if there is any difference. Try making rule 2 higher salience than rule 1. Try asserting different values for the counter, like new Counter( 2 ).
[]s
Edson
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com