From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of 
esteban.alive...@gmail.com
Sent: 16 October 2010 17:17
To: Rules Users List
Subject: Re: [rules-users] Flows, Subflows and fault.

Hi Thomas,
Here you have some answers (in blue) to your complains:

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 - or it returns when 
the entire process has been completed.
Challenge 1a: How to detect when the process has finished and use it in a 
synchronous manner.
Solution: A ProcessEventListener which completes a countdown latch when teh 
process has completed.
Challenge 1b: Subprocesses also trigger process events
Solution: Have the latch track the first process that started (the parent) and 
only return when that process completes.

Another solution: after startProcess() returns, you can check the status of the 
process (unfortunately, you need a cast):
        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) 
ksession.startProcess("org.drools.state");
        // should be in state A
        assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
[TS] But what I would actually need is a "while(processInstance.getState == 
STATE_ACTIVE) {sleep(10);} - which is ugly. It would be nice if the API lets me 
do process.awaitCompletion().


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't 
registered the process just stalls with a message.
Solution: Make sure code is perfectly written and doesn't have any bugs... hope 
that it doesn't happen in production ... complain on mailing list and add TODO 
to raise issue.

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)

Issue 3: Fault nodes seem to be the correct way to say that something has gone 
wrong and the process should terminate.
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.
Solution: Add an event listener which detects when a fault node is being 
entered and extracts the details - seems like a big hack surely there is a 
better way.

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.
[TS] Am I right that I need an exception handler for every fault name that is 
used? I'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.

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.
Challenge: The parent process isn't marked as complete - 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 - which 
will never be called as the process has already aborted. The parent process 
just stalls left in the state of active forever.
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...

Another solution: Throwing an exception inside the handler should solve this 
issue too.


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com

2010/10/15 Swindells, Thomas <tswinde...@nds.com<mailto:tswinde...@nds.com>>
I've just started to use Drools Flow in anger and I'm really struggling to 
understand the correct way to use it and think I am missing something.

This is what I want to achieve:
The app code executes a StartProcess command and waits for the process to 
return (1 main process per session, 1 session per thread).
The process either succeeds, or it fails with a result.
A process could be complicated so I want to split it up into a parent process 
calling subprocesses.
I want to minimize boilerplate code (particularly in the ruleflow files) and 
keep the workflows as simple and maintainable as possible.

It sounds simple enough and doesn't seem to be particularly unusual.

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 - or it returns when 
the entire process has been completed.
Challenge 1a: How to detect when the process has finished and use it in a 
synchronous manner.
Solution: A ProcessEventListener which completes a countdown latch when teh 
process has completed.
Challenge 1b: Subprocesses also trigger process events
Solution: Have the latch track the first process that started (the parent) and 
only return when that process completes.

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't 
registered the process just stalls with a message.
Solution: Make sure code is perfectly written and doesn't have any bugs... hope 
that it doesn't happen in production ... complain on mailing list and add TODO 
to raise issue.

Issue 3: Fault nodes seem to be the correct way to say that something has gone 
wrong and the process should terminate.
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.
Solution: Add an event listener which detects when a fault node is being 
entered and extracts the details - seems like a big hack surely there is a 
better way.

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.
Challenge: The parent process isn't marked as complete - 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 - which 
will never be called as the process has already aborted. The parent process 
just stalls left in the state of active forever.
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...

Thomas

________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com<mailto:postmas...@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
**************************************************************************************

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users


________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@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
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to