<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.gmailquote
        {mso-style-name:gmail_quote;}
span.e
        {mso-style-name:e;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Yang,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If you want to evaluate the remaining rules in the transaction
you will need to catch and handle your errors rather than throw them to the
engine. &nbsp;This is consistent with other products, such as ILog
JRules.&nbsp; &nbsp;If you are catching and handling your own errors, you can
always grab the rule number and exception and add them to your reply. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'><img width=132 height=23 id="Picture_x0020_1"
src="cid:image003.jpg@01C7E645.02B09F90" alt=railinc><o:p></o:p></span></b></p>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>____________________________________________________<o:p></o:p></span></b></p>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>Barry Knapp<o:p></o:p></span></b></p>

<p class=MsoNormal><b><span style='font-size:8.0pt;font-family:"Arial","sans-serif";
color:#1F497D'><a href="mailto:Barry.Knapp@RailInc.com">Barry.Knapp@RailInc.com</a><o:p></o:p></span></b></p>

<p class=MsoNormal><b><span style='font-size:8.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>919.651.5039<o:p></o:p></span></b></p>

<p class=MsoNormal><b><span style='font-size:8.0pt;font-family:"Arial","sans-serif";
color:#1F497D'>MSN Messenger <a href="mailto:barry25@hotmail.com">barry25@hotmail.com</a>
<o:p></o:p></span></b></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Yang Song<br>
<b>Sent:</b> Friday, August 24, 2007 11:16 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] How to catch Exceptions when firing rules<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>Thanks a lot for the answer, Mark. But I don't think it
makes sense. <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Because in some scenarios, you cannot guarantee the
consequence part of rule is 100% correct -- there could be errors happening in
run-time which are hard to predict, especially when a complex action or logic
will be executed as the concequece. <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>There should at least be some mechanisms to tell whoever
fires the rule that there is something wrong during the rule firing process,
then and he&nbsp;can&nbsp;do something, e.g. create a new session. Also it
should enable the&nbsp;rule firer&nbsp;to catch these exceptions and do the
clean up work silently -- instead of leaving these things on the stderr even
cannot be seen in the logs. This will make the program depending on the JBoss
Rules to be more robust. <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>What do you think? If JBoss Rules already has the ability to
do this job, can you please let me know?<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Thanks again,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Yang<br>
<br>
&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span class=gmailquote>On 8/24/07, <b>Mark Proctor</b> &lt;<a
href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:</span>
<o:p></o:p></p>

<div>

<p class=MsoNormal>Once an exception is thrown on a conseuqence the current
session is considered invalid. You'll need to add the try catch inside of the
actual consequence.<br>
<br>
Mark<br>
Yang Song wrote: <o:p></o:p></p>

<div>

<div>

<p class=MsoNormal>Hi, <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>Anyone knows how to catch the exception when firing the
rules? <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>I wrapped the session.fireAllRules() method using
try...catch, however it doesn't work: when someone wrote&nbsp;bad code in the
rule's action part, the Exception will be thrown and printed to the stderr, and
this will make the rule engine stop working --&nbsp;the try...catch outside
doesn't help anything. <o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>If&nbsp;&nbsp;the exception&nbsp;thrown from&nbsp;the rule's
action part&nbsp;can be caught externally,&nbsp;the system can be protected
from interrupting Exception.<o:p></o:p></p>

</div>

<div>

<p><span style='font-family:"Courier New";color:#3333FF;background:white'>try {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.debug(&quot;Firing rules in :
&quot; + getName());</span><o:p></o:p></p>

<p><span style='font-family:"Courier New";color:#3333FF;background:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
session.fireAllRules();</span><o:p></o:p></p>

<p><span style='font-family:"Courier New";color:#3333FF;background:white'>}
catch (Exception e) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _log.info(&quot;Error when firing
rules: &quot;, e);<br>
}</span> <o:p></o:p></p>

<p>Thanks, <br>
Yang<o:p></o:p></p>

</div>

</div>

<pre style='text-align:center'>

<hr size=4 width="90%" align=center>

</pre><pre><o:p>&nbsp;</o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>rules-users mailing list<o:p></o:p></pre><pre><a
href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><o:p></o:p></pre><pre><a
href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></pre><pre>&nbsp; <o:p></o:p></pre>

<p class=MsoNormal><br>
&nbsp;<o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><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><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>