[rules-users] firing rules twice in single session on single object

abhinay_agarwal abhinay_agarwal at infosys.com
Thu Oct 11 08:00:12 EDT 2012


If you want the same rule to fire again and again then just modify the fact
such that the WHEN condition is satisfied.

For example in the HELLO WORLD sample Code :

rule "Hello World"
no-loop
    when
        m : Message( status == Message.HELLO, myMessage : message )
    then
        System.out.println( myMessage );
        m.setMessage( "Goodbye cruel world" );
        m.setStatus( Message.GOODBYE );
        update( m );
end

You can alter and change the m.setStatus( Message.HELLO) and you can see the
rule gets refired again.

But this will make the rule to refire itself again and again, making it fall
inside an infinite loop, which is logically not acceptable(For this reason
"no-loop" exists).

So my opinion would be modify your rule set to make few rules, such that
each of them satisfies under some condition and gets fired !!

Regards,
Abhinay



--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-firing-rules-twice-in-single-session-on-single-object-tp4020220p4020224.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list