how to use another service if one user task get error in Multi Instance sequential case

359 views
Skip to first unread message

Vasif Abdul

unread,
Oct 13, 2015, 1:41:17 AM10/13/15
to camunda BPM users
Hi camunda team.
I want to know is it possible to call another service when one user task get error in mutliinstance sequential  case before all multiinstance task complete
Thanks.

Roman Smirnov

unread,
Oct 13, 2015, 2:59:03 AM10/13/15
to camunda BPM users
Hi Vasif,

Could elaborate it a little bit more?

What kind of error happens? What kind of service do you want to call? What should the service do?

Cheers,
Roman

Vasif Abdul

unread,
Oct 13, 2015, 5:46:39 AM10/13/15
to camunda BPM users
Hi Roman

Suppose that we have approve task which is multi-instance and sequential. What we are trying to do is that when one of the users doesn't approve then other approve tasks should not be created, and workflow should continue in the other direction, for example calls service task.We tried to set conditions on sequence flows but it only switches to next tasks when all approve tasks are created and finished. Please help us 

Philipp Ossler

unread,
Oct 14, 2015, 2:34:46 AM10/14/15
to camunda BPM users
Hi Vasif,

you change your multi-instance task to a multi-instance subprocess that contains the task. When the task ends (or running in a timeout) then the result is checked and the multi-instance subprocess may end. Otherwise, you can model it as a loop with condition (like do-while).


Greetings,

Philipp

Vasif Abdul

unread,
Oct 14, 2015, 8:19:32 AM10/14/15
to camunda BPM users
Hi Philipp

Thanks. your answer helped me to solve my problem. Now i have another issue. Suppse i have one ServiceTask between usertasks . if i throw ProcessEngineException in java delegate class .is there any way to complete all other tasks and process after throwing exception??

Philipp Ossler

unread,
Oct 14, 2015, 9:06:14 AM10/14/15
to camunda BPM users
Hi Vasif,

no, there is no built-in way to do that. You should model it with Error Events [1]. Catch the technical exception in java delegate and throw a bpmn error. The error should catch somewhere (e.g. as boundary event) and end the open tasks. 


Please open a new issue if you have additional questions.


Greetings,

Philipp

  

Vasif Abdul

unread,
Oct 14, 2015, 9:37:55 AM10/14/15
to camunda BPM users
Hi Philipp

Thanks for replying so quickly. If i get error related camunda database that i cannot catch is there way to rollback or continue process  ?

Cheers
Vasif.

Philipp Ossler

unread,
Oct 15, 2015, 2:19:27 AM10/15/15
to camunda BPM users
Hi Vasif,

in a java delegate you should only catch business errors or known technical errors (zB. timeout while ws request). If an error occurred that is related to the camunda db (e.g. optimistic lock expection), the transaction will rollback. Have a look at [1] for more details. 

Greetings,
Philipp 

Vasif Abdul

unread,
Oct 15, 2015, 4:31:06 AM10/15/15
to camunda BPM users
Hi Philipp

I understood your explanation. So i have one question more. can i use camunda transaction (mybatis) for example i have two service task between two stable state.if first service task complete successfully but second throw exception then i will do first service task again and it will write db twice. if i use same transaction with camunda  then my first service task also can be rolled back. So i want to use mybatis transaction for such situations. Help me pls.

Cheers 
Vasif.

Philipp Ossler

unread,
Oct 15, 2015, 4:50:41 AM10/15/15
to camunda BPM users
Hi Vasif,

please read the chapter about transactions [1]. You can Spring or JTA transaction manager to interact with camunda [2]. However, you can control the transaction boundaries with asynchronous continuation [3]. Additionally, you can use compensation events to compensate (e.g. undo) completed tasks if you leave the boundary of a transaction. [4]

Greetings,
Philipp

Vasif Abdul

unread,
Oct 15, 2015, 5:24:33 AM10/15/15
to camunda BPM users
Hi Philipp 
We are not using container for our aplication. Sorry i didnt say it before. We use embedded camunda and using Sql transaction. How can i use same transaction with camunda?

Philipp Ossler

unread,
Oct 15, 2015, 5:38:53 AM10/15/15
to camunda BPM users
Hi Vasif,

you can not use the same transaction as camunda. You have to provide a transaction manager for camunda if you want to do things in the same transaction. For example, you can use Spring to provide a transaction manager. This works for an application server and also standalone. 
However, a simpler way may be compensation events. When an error occurred then you throw a compensation event. The compensation event is caught by all tasks that are completed successful and have a compensation handler (a task attached to a compensation boundary event). The compensation handler should undo / compensate the actions of the task, for example delete db entities.  

Greetings,
Philipp

Vasif Abdul

unread,
Oct 15, 2015, 6:00:29 AM10/15/15
to camunda BPM users
Hi Philipp

Thanks. Now i know how to solve this problem with your help.

Cheers.
Vasif
Reply all
Reply to author
Forward
0 new messages