<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:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" 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:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
-->
</style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</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-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span lang="EN-US" style="font-size:10.0pt;
font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>esteban.aliverti@gmail.com<br>
<b>Sent:</b> 16 October 2010 17:17<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] Flows, Subflows and fault.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Hi Thomas,<o:p></o:p></p>
<div>
<p class="MsoNormal">Here you have some answers (in blue) to your complains:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Issue 1: startProcess is semi-synchronous. It starts the process, runs through as many nodes as it can until it gets to a non-synchronous task (rules, long lived customer work item etc) at which point it returns &#8211; or it returns when the
 entire process has been completed.<o:p></o:p></p>
<p class="MsoNormal">Challenge 1a: How to detect when the process has finished and use it in a synchronous manner.<o:p></o:p></p>
<p class="MsoNormal">Solution: A ProcessEventListener which completes a countdown latch when teh process has completed.<o:p></o:p></p>
<p class="MsoNormal">Challenge 1b: Subprocesses also trigger process events<o:p></o:p></p>
<p class="MsoNormal">Solution: Have the latch track the first process that started (the parent) and only return when that process completes.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span style="color:#000099">Another solution: after startProcess() returns, you can check the status of the process (unfortunately, you need a cast):&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#000099">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;WorkflowProcessInstance processInstance = (WorkflowProcessInstance)&nbsp;ksession.startProcess(&quot;org.drools.state&quot;);</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#000099">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// should be in state A</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#000099">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">[TS] But what I would actually need is a &#8220;while(processInstance.getState == STATE_ACTIVE) {sleep(10);} &#8211; which is ugly. It would be nice if the API lets me
 do process.awaitCompletion().<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Issue 2: Drools Flow is littered with error checking code which just prints to System.err and either carrys on or just stop. Eg if a work item handler isn&#8217;t registered the process just stalls with a message.<o:p></o:p></p>
<p class="MsoNormal">Solution: Make sure code is perfectly written and doesn&#8217;t have any bugs... hope that it doesn&#8217;t happen in production ... complain on mailing list and add TODO to raise issue.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span style="color:#000099">You are absolutely true about this. We are trying to remove all the System.err and replace them with a proper error treatment (like abort the process)</span> &nbsp;<o:p></o:p></p>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal">Issue 3: Fault nodes seem to be the correct way to say that something has gone wrong and the process should terminate.<o:p></o:p></p>
<p class="MsoNormal">Challenge: How does the calling code actually work out what the fault was and get the variable? The guide talks very very briefly about exception handlers but from what I can understand this is a way for the process to define what to do
 in this conditions. I want the process to be aborted and the calling application to be informed of this and the details.<o:p></o:p></p>
<p class="MsoNormal">Solution: Add an event listener which detects when a fault node is being entered and extracts the details &#8211; seems like a big hack surely there is a better way.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span style="color:#000099">Another Solution: you could throw an exception inside your exception handler. This way you will abort the process and get the exception in your code.</span> &nbsp;<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">[TS] Am I right that I need an exception handler for every fault name that is used? I&#8217;m really struggling to understand from the single paragraph in the doc
 how it is meant to work, particularly if I am calling an arbitrary subflow.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Issue 4: If a child process executes a fault node it is aborted. The parent process is set to wait for completion and has the child node as not being independent so I would expect that the parent process should also be marked as aborted.<o:p></o:p></p>
<p class="MsoNormal">Challenge: The parent process isn&#8217;t marked as complete &#8211; it still has a status of Executing. However the process is stalled. Looking at subprocessNodeInstance internalTrigger (line 117) if the node returns a state of completed then trigger
 completed is called, otherwise it just adds a process listener &#8211; which will never be called as the process has already aborted. The parent process just stalls left in the state of active forever. &nbsp;<o:p></o:p></p>
<p class="MsoNormal">Sollution: ?? Hack my fault listener to work round the issue and update the parent process, make the processEventListener assert that if a child process is aborted then we should return? Ask on the mailing list to get me out of a blind
 alley and point me to the correct drools way of doing it...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#000099">Another solution: Throwing an exception inside the handler should solve this issue too.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br clear="all">
<br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<br>
- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com
</a><br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal">2010/10/15 Swindells, Thomas &lt;<a href="mailto:TSwindells@nds.com">TSwindells@nds.com</a>&gt;<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I&#8217;ve just started to use Drools Flow in anger and I&#8217;m really struggling to understand the correct way to use it and think I am missing something.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">This is what I want to achieve:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The app code executes a StartProcess command and waits for the process to return (1 main process per session, 1 session per thread).<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The process either succeeds, or it fails with a result.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">A process could be complicated so I want to split it up into a parent process calling subprocesses.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I want to minimize boilerplate code (particularly in the ruleflow files) and keep the workflows as simple and maintainable as possible.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It sounds simple enough and doesn&#8217;t seem to be particularly unusual.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Issue 1: startProcess is semi-synchronous. It starts the process, runs through as many nodes as it can until it gets to a non-synchronous task (rules, long lived customer work item
 etc) at which point it returns &#8211; or it returns when the entire process has been completed.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Challenge 1a: How to detect when the process has finished and use it in a synchronous manner.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Solution: A ProcessEventListener which completes a countdown latch when teh process has completed.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Challenge 1b: Subprocesses also trigger process events<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Solution: Have the latch track the first process that started (the parent) and only return when that process completes.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Issue 2: Drools Flow is littered with error checking code which just prints to System.err and either carrys on or just stop. Eg if a work item handler isn&#8217;t registered the process
 just stalls with a message.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Solution: Make sure code is perfectly written and doesn&#8217;t have any bugs... hope that it doesn&#8217;t happen in production ... complain on mailing list and add TODO to raise issue.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Issue 3: Fault nodes seem to be the correct way to say that something has gone wrong and the process should terminate.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Challenge: How does the calling code actually work out what the fault was and get the variable? The guide talks very very briefly about exception handlers but from what I can understand
 this is a way for the process to define what to do in this conditions. I want the process to be aborted and the calling application to be informed of this and the details.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Solution: Add an event listener which detects when a fault node is being entered and extracts the details &#8211; seems like a big hack surely there is a better way.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Issue 4: If a child process executes a fault node it is aborted. The parent process is set to wait for completion and has the child node as not being independent so I would expect
 that the parent process should also be marked as aborted.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Challenge: The parent process isn&#8217;t marked as complete &#8211; it still has a status of Executing. However the process is stalled. Looking at subprocessNodeInstance internalTrigger (line
 117) if the node returns a state of completed then trigger completed is called, otherwise it just adds a process listener &#8211; which will never be called as the process has already aborted. The parent process just stalls left in the state of active forever. &nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Sollution: ?? Hack my fault listener to work round the issue and update the parent process, make the processEventListener assert that if a child process is aborted then we should
 return? Ask on the mailing list to get me out of a blind alley and point me to the correct drools way of doing it...<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thomas<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="100%" align="center">
</div>
<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;
color:gray"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the
<a href="mailto:postmaster@nds.com" target="_blank">postmaster@nds.com</a> 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.<br>
<br>
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<br>
**************************************************************************************</span><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>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@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.<br>
<br>
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<br>
**************************************************************************************<br>
</font>
</body>
</html>