-
1. Re: Exception handling in JBPM4 ?
saraswati.santanu Feb 15, 2010 1:27 PM (in response to atuljoshi)Exception is strictly for exceptional conditions.. specially runtime exceptions. This has nothing to do with jBPM, this is a general practice for Java (and for most of other languages which has exception construct). You might like to refer to Effective Java, chapter 9.
Exception should not be used as a valid business case. If you think you can recover from an exception (and create history entries etc.) then you should catch and handle it gracefully. Committing some information on the event of an exception is dangerous and beats the purpose of transaction. I do not think will be supported in any way.
-
2. Re: Exception handling in JBPM4 ?
hernanrodriguez Feb 19, 2010 9:37 AM (in response to atuljoshi)I have the same problem with Java Task nodes.
For example, I'm using the following model:
(java1, java2 and java 3 are Java Task. state1 is a State node)
When start the execution, this stop in "state1". Then, I resume the process instance. If "java3" throws an Exception the transaction is rolled back until "state1".
If "java1" and "java2" were successfully completed.. why are rolled back?
It's possible commit the transaction after each node?. This is possible with "Custom Nodes", but I need to do the same with Java Task nodes.
The source of the model is:
<?xml version="1.0" encoding="UTF-8"?>
<process key="test" name="test" xmlns="http://jbpm.org/4.2/jpdl">
<start g="19,19,48,48" name="start1">
<transition g="33,-7" name="to java1" to="state1"/>
</start>
<state g="60,71,92,52" name="state1">
<transition g="13,-29" name="to java1" to="java1"/>
</state>
<java class="cl.pred.cmh.bpm.events.controller.TraspasoController" g="136,140,92,52" method="test" name="java1" var="respuesta1">
<transition g="2,-17" name="to java2" to="java2"/>
</java>
<java class="cl.pred.cmh.bpm.events.controller.TraspasoController" g="281,281,92,52" method="test" name="java3" var="respuesta3">
<transition g="3,-26" name="to end1" to="end1"/>
</java>
<java class="cl.pred.cmh.bpm.events.controller.TraspasoController" g="203,207,92,52" method="test" name="java2">
<transition g="10,-21" name="to java3" to="java3"/>
</java>
<end g="372,332,48,48" name="end1"/>
</process>Any suggestion will be greatly appreciated.
-
3. Re: Exception handling in JBPM4 ?
atuljoshi Feb 18, 2010 3:01 AM (in response to hernanrodriguez)How you commit the transaction after each node by using the Custom Nodes in custom class ? Could you please send us example on the same. Thanks in advance -
4. Re: Exception handling in JBPM4 ?
yogitabartake Feb 19, 2010 8:56 AM (in response to atuljoshi)I am facing a similar problem. When an error occurs I want the user to retry the activity. For that I need to commit all the previously succesfully completed activities. Please Help!!! -
5. Re: Exception handling in JBPM4 ?
kukeltje Feb 20, 2010 9:51 AM (in response to yogitabartake)Transaction demarcation is done by using the async attribute on nodes. See the documentation for this. -
6. Re: Exception handling in JBPM4 ?
yogitabartake Feb 22, 2010 9:59 AM (in response to kukeltje)Thanks Ronald .
I have another related query.
I am trying to suspend the exeution when I get an error and later resume the same. But the only way I could find is by using the ExecutionImpl's suspend/resume method.
How can I achieve the same using services?
-
7. Re: Exception handling in JBPM4 ?
swiderski.maciej Feb 22, 2010 12:29 PM (in response to yogitabartake)What about following scenario:
- there are 4 nodes (regardless of type) that are executed as one transaction.
- some of the nodes modify external systems via different protocols
- no exceptions are thrown from nodes
- runtime exception is thrown due to some db issues
Transaction will be rolled back but changes made to external system are not rolled back since they were not part of the transcation (for example web service call).
Have you put any thoughts into that? I was wondering if some sort of compensation mechanism could be introduced to the execution where nodes that take part in transaction can inform runtime engine what to invoke in case of roll backs. This could give kind of undo operation for already finished nodes and should not cause any problems when process will go thru them again.
What's your opinion about it? Does it sound reasonable?
Cheers,
Maciej
-
8. Re: Exception handling in JBPM4 ?
kukeltje Feb 22, 2010 3:01 PM (in response to yogitabartake)new questions in new topics please -
9. Re: Exception handling in JBPM4 ?
kukeltje Feb 22, 2010 3:02 PM (in response to swiderski.maciej)And these fundamental questions even more so (new topic) -
10. Re: Exception handling in JBPM4 ?
atuljoshi Feb 23, 2010 8:46 AM (in response to kukeltje)I used async attribute for the activities in the process , This attributes help us to commit the successfully completed activities , but how can I re execute the activity which haveing the exception, because jbpm4 will rollback the execution id of the activity which having the exception, How can I achieve the same ? -
11. Re: Exception handling in JBPM4 ?
swiderski.maciej Feb 23, 2010 2:22 AM (in response to kukeltje)Agree, sorry for that. New discussion started - How to handle rollback due to runtime errors
-
12. Re: Exception handling in JBPM4 ?
yogitabartake Feb 24, 2010 5:31 AM (in response to atuljoshi)Atul I am trying the same thing in the following manner:
I used async for the activities. When an exception occurs, in the catch block I am suspending the execution n later resuming it. With this the id that u mentioned does not get lost.
But with this I am not able to take the execution ahead. This I have mentioned in another thread. Is there any way to execute that activity again? Please Help!!!!
-
13. Re: Exception handling in JBPM4 ?
atuljoshi Mar 1, 2010 7:37 AM (in response to atuljoshi)I have changed the process design as follows.- Instead of System Activity call Sub Process, name as "Sub_process_catch_Exception" ,
- In this sub process Instead of calling the system activity add Decision activity (Implement Business Logic in decision instead of SystemActiviy),
- If Decision activity executed successfully then
- Trigger Wait (State Node) activity after resolving the exception by using the execution Id of the activity
- I am able to implement Retry, Skip, Max No. of Retries and timeout for all JAVA activities present in my Workflow design, using this common solution,
- I have almost completed my workflow design, if I want to implement Exception Handling I need to change my design from scratch,
-
JPDL FILES.zip 12.5 KB
-
14. Re: Exception handling in JBPM4 ?
yogitabartake Mar 1, 2010 7:53 AM (in response to atuljoshi)Thats a good solution but a bit cumbersome Atul.
I am doing retry in the following manner and its working fine.
public
void retry(String id)
{
ProcessEngine processEngine =
null ;
processEngine =
new Configuration().setResource("jbpm.cfg.xml").getProcessEngine();
ManagementService managementService = processEngine.getManagementService();
Job job = managementService.createJobQuery().processInstanceId(id).uniqueResult();
managementService.executeJob(job.getId());
}
With this u wont have to redesign your Workflow. but m still stuck with skip. I have started a new thread for this.