how to handle error or exception in jbpm workflow

1,911 views
Skip to first unread message

Kanahaiya Gupta

unread,
Mar 15, 2016, 1:27:07 AM3/15/16
to jBPM Usage
Hi ,

I am developing one jbpm flow which looks like below-


start---->ServiceTask1---output-->ServiceTask2-----output--->ServiceTask3-->end

and want to log the exception or error if it occurs  in any of the service task either 1,2 or 3 (inside workitemhandler).But don't know how to handle exception or error in jbpm.


So,Is there any small working example or link which shows how to handle error or exception in jbpm workflow.(Plz don't suggest jbpm-examples link i have already visited there are lot of flows together so not able to get the clear pictures)

Thanks for your help in advance.


Thanks & Regards
Kanahaiya Gupta

Maciej Swiderski

unread,
Mar 15, 2016, 9:06:41 AM3/15/16
to Kanahaiya Gupta, jBPM Usage
in general, you have two options:
- include error handling within your work item handler define whatever is needed to handle exceptions
- make use of error catch events (including event subprocess) to handle exceptions within your process definition. 

First option is very close to regular programming practices as it requires you to handle exceptions on code level. usually good for handling technical exceptions rather than business logic errors. For business logic errors, better fit is with error catch events within process - either boundary error events attached to given service task or event subprocess with start error event that will deal with errors.

Here you can find an example of the second approach where we call web service endpoint and handle errors if any:

Maciej
--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/e6e6afbd-5c20-4c75-8939-329b2e8eb45a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maciej Swiderski

unread,
Mar 18, 2016, 3:46:52 AM3/18/16
to Kanahaiya Gupta, jbpm-...@googlegroups.com
this is as expected as engine runs in stack mode so it continues with other nodes when handler triggers it - via completeWorkItem

Maciej

2016-03-17 7:19 GMT+01:00 Kanahaiya Gupta <kanhaiya...@gmail.com>:
Hi Maciej,

It solved my problem...thanks..:)

One more question..
whenever i use below statement in my workitemhandler
workItemManager.completeWorkItem(workItem.getId(), responses);
 it does not execute any statement after this .it passes the control further and execute another node then execute  workitemhandler associated with that..but once all node visited then its trying to execute all the statement which i have wrote after that line in reverse order....?? which i could not understand.

Can you please help here

On Wed, Mar 16, 2016 at 12:31 PM, Kanahaiya Gupta <kanhaiya...@gmail.com> wrote:
Thanks Maciej for your response...!!

I hope it will solve my problem.let me try it out.
Reply all
Reply to author
Forward
0 new messages