Miguel,
I think your work item handler should not be throwing an exception, just because a java
exception is low-level and linked to one specific implementation and we try to keep the
processes a little higher-level.
So what could you do then to model exceptional situations when executing a work item? I
suggest you use a try-catch block to catch the java exception and translate that into
something higher-level, like:
- your work item can contain result parameters, in case of some failure you could fill in
a special result parameter with some data, the process instance can then map this result
data to some process variable which will allow you to use this data, for example in a XOR
split node immediate after this work item node to check for exceptional situations, or in
an on-exit action linked to the workItemNode (which could then for example also throw a
fault so that the nested exception handler mechanism kicks in)
- your work item handler could decide to send a signal to the process instance to signal
the occurrence of some exceptional event, and you could use an event handler to listen to
that event
Depending on your exact use case, I can probably think of a few more alternatives (like
using abortWorkItem instead of completeWorkItem), but they might not be all ready to use
out-of-the-box.
Kris
----- Original Message -----
From: miguel machado
To: Rules Users List
Sent: Thursday, April 01, 2010 1:57 PM
Subject: Re: [rules-users] How to do Exception Handling???
Hi,
I'm not sure this will help you out, but in what comes to the system i'm
currently developing (using drools expert), i've got this method
"runRuleEngine" that collects facts and fire rules on them and i am able to
catch any sort of error within the drools execution by surrounding that with try {} catch
(Exception e) {}.
The important part is that it took me a while to figure that out cuz eclipse didn't
force me handle that, as if the called method didn't have "throws" (it
usually shows a compilation error otherwise, right?).
Just a thought.
_ miguel
On Wed, Mar 31, 2010 at 9:44 PM, nanic23 <nanic23(a)hotmail.com> wrote:
I have a ruleflow that handles exceptions when they are raised by a "Fault"
node but I am not being able to accomplish the same if an exception is
thrown by a workItem or an action node instead.
I have a workItem node with a work item handler that throws a
RuntimeException. My exception handler in the composite node is not catching
this exception.
So, question
1) how can I handle runtime exceptions thrown by my workItemHandlers?
2) how can I get a hold of the exception to log the stack trace?
Any ideas or tips are very appreciated.
Nick.
--
View this message in context:
http://n3.nabble.com/How-to-do-Exception-Handling-tp689387p689387.html
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
"To understand what is recursion you must first understand recursion"
------------------------------------------------------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm