[rules-users] firing rules twice in single session on single object
Sai Nadh
adisya.sai at gmail.com
Fri Oct 12 03:18:34 EDT 2012
good morning sir,
first of all
i am very thankful to your support,
but it is not working properly, first of all i want to explain my
requirements
please pay little time for me
I have 1000 records of some data like sales amount
I have two rules like below
rule "Mr First Rule"
salience 100
when
#conditions
sales : Sales (salesAmount >=200)
then
#actions
sales.set SalesMessage("goodsales");
end
rule "My second Rule"
salience 80
when
#conditions
sales : Sales (salesAmount<200)
then
#actions
sales.set SalesMessage("badsales");
end
Here i want to insert facts from the list
if the salesAmount list is modified in the same session( fact object is
modified)
how can i fire the rules again in the same session
please help me in this scenario and if possible please provide some docs
also
regards
sai
On Thu, Oct 11, 2012 at 5:30 PM, abhinay_agarwal <
abhinay_agarwal at infosys.com> wrote:
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
*Regards*
*SAI BABA NADH*
+91 7411680125
* *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121012/cd678192/attachment-0001.html
More information about the rules-users
mailing list