On 30 August 2011 14:27, Dean Whisnant <span dir="ltr">&lt;<a href="mailto:dean@basys.com">dean@basys.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
My project involves rule creation by customers, business analysts, and developers.  We have a base set of rules that fire for every transaction and then we fire custom rules within a stateful session.  An issue I&#39;ve started to run into is rules being created that fire endlessly.  I initialize the session with an event listener that we use to extract all rules fired for each line item of a transaction.  Once the session is initialized and all rules from various agenda groups loaded we do a fireall rules.<br>

<br>
My questions are:<br>
1) how can I detect I have a runaway rule/rules.<br>
        Is there a method or listener that could detect this for me?  Does anyone have a formula they use to do so?  I had thought that I could use my event listener that I track the rules with to grab the last X number of rules fires and see if rule y gets fired more that z times.  But is there a simpler method?<br>
</blockquote><div><br>It&#39;s not even as simple as that. ;-) Multiple firing of a rule r within n firings may not be loops if this happens with different facts bound to patterns.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

2) once I&#39;ve detected a runaway rule, how can I gracefully stop drools rule execution? I read of the command drools.halt in different posts, but not sure if this would be what I&#39;m looking at doing.<br></blockquote>
<div><br>If you detect it during a consequence execution, throw an exception and catch it with a custom consequence exception handler.<br><br>Using a limit on fire all rules might be another way, in combination with logging all activations.<br>
 <br>Finally, someone with a little savvy should be able to detect some just by looking at them. The telltale marks are well known...<br><br>-W<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
<br>
Any thoughts are appreciated.<br>
<br>
Thank you!<br>
<br>
Dean<br>
                StatefulKnowledgeSession ksession = buildOutgoingStatefulKnowledgeSession(supportingUDTList);<br>
                // AgendaEventListener agendaListener = new HipaaAgendaListener();<br>
                ksession.addEventListener(_ruleLog);<br>
<br>
                for (int i = 0; i &lt; _agendaGroups.size(); i++)<br>
                {<br>
                        if (_log.isDebugEnabled()) _log.debug(&quot;Focus on Agenda Group &quot; + _agendaGroups.get(i));<br>
                        ksession.getAgenda().getAgendaGroup(_agendaGroups.get(i)).setFocus();<br>
                        // Fire them all<br>
                        try<br>
                        {<br>
                                ksession.fireAllRules();<br>
                        }<br>
                        catch (Exception e)<br>
                        {<br>
                                _log.error(&quot;FireAllRules exception. Error=&quot; + e.getMessage()); // error<br>
                        }<br>
                }<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>