If you want to stop execution you can do
kcontext.getKnowledgeRuntime().halt();
However this will only get executed once all the rules have been evaluated so it can’t be
used to prevent null pointer exceptions in condtions.
Another approach which may (or may not) work is to get your condition to actually throw an
exception if the condition doesn’t match this will normally stop the execution as well.
Eg
function isNull(Object o)
if(o == null) throw new ValidationException(“Object is null :(“);
return false;
end
rule “blagh”
when
eval(isNull(someObject))
then
//this will never be reached as an exception will be thrown
End
(you may need to fiddle with syntax and use a java method or something.
The other key thing to remember though is if you have structured your rules correctly
(null check as the very first condition) then all 100 rules will share the same null check
node and you will only be doing it once not 100 times anyway and so it will make little
difference on performance. (And a null check is very fast anyway). Don’t optimize until
you know you actually have to – there are likely to be other far more important
performance issues in your application anyway
Thomas
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Sathya Prakash
Sent: 16 February 2011 22:51
To: Mauricio Salatino; michael.anstis(a)gmail.com
Cc: Rules Users List
Subject: Re: [rules-users] how to stop rule execution
I got great Idea by this discussion.
If there is no way of stopping rules then I can do this null condition check before
executing rules. Adding one action in JBoss ESB will solve problem.
Please suggest me.
Many Thanks in advance.
Regards,
Sathya Prakash.
On Thu, Feb 17, 2011 at 2:39 AM, Sathya Prakash
<prakashagarval@gmail.com<mailto:prakashagarval@gmail.com>> wrote:
Thanks for your suggestion..
But let us assume i have 100 rules based on single response. When response is null then if
i am doing null check in all rules then it degrades the performance. My application hits
are million per day. if 1 % percent fails think about the impact.
Regards,
Sathya Prakash.
On Thu, Feb 17, 2011 at 2:26 AM, Mauricio Salatino
<salaboy@gmail.com<mailto:salaboy@gmail.com>> wrote:
you can do something like:
rule "Error Check"
salience 100
when
error condition check
then
System.Out.Println("Response has errors");
XXXXXXXXXXXXXXXXXXXXXXXX to exit from rule execution
insert(Stop())
end
rule "Rule-01"
salience 99
when
not(Stop())
repsonse.getxx()
then
end.
2011/2/16 Sathya Prakash
<prakashagarval@gmail.com<mailto:prakashagarval@gmail.com>>
Hi,
How to stop rule execution in technical rule,
Example
rule "Error Check"
salience 100
when
error condition check
then
System.Out.Println("Response has errors");
XXXXXXXXXXXXXXXXXXXXXXXX to exit from rule execution
end
rule "Rule-01"
salience 99
when
repsonse.getxx()
then
end.
if first rule then part executed means the response is error hence we should not execute
second.
Is there any way to exit rule execution.
Regards,
Sathya Prakash.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
--
- CTO @
http://www.plugtree.com
- MyJourney @
http://salaboy.wordpress.com
- Co-Founder @
http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
--
Cheers,
Sathya Prakash.
సత్య ప్రకాష్.
--
Cheers,
Sathya Prakash.
సత్య ప్రకాష్.
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************