HI
Before starting I would like to clarify that the subject of this topic has become a blocking problem for me and my team for several months, so welcome to any kind of help !
I have a BPMN model which contains a user Task ( UT) with a taskListner ( my taskListner contains a business code and it’s will be called when UT is completed).
So in order to complete the user task :
-
From my Frontend App I do a Rest Call (POST) to :http://localhost:8080/engine-rest/task/taskId/complete with some Json data in body
-
Camunda completes my user Task ( UT)
-
//in parallel// The process goes to next task
-
//in parallel// Camunda executes method notify() of my tasklistner (read json data and execute business code) ,Note that :if an exception occurred in my business code, it will be too late to deal with it
My Problem is too simple : I need that Camunda completes my task UT and goes to next task only if the Tasklistner (my business code) is executed without error/exception ( if an exception occurred ==>the process stays in my task (UT), and require the user to try again to complete this task ).
Hi @camunda_beginner,
Is your tasklistener attached to UT user task or to a different user task? Can you please share your model.
1.On task completion - invoke business logic and outcome success/failure on variable
2.Check variable marked success/failure
3. in case failure retry create task and assign to user
japree_pj Thanks for your response ,but this solution is already discussed here.
Yes my tasklistener is attached to UT
Hi @camunda_beginner,
You can simply throw ProcessEngineException. (no need for the gateway in this case)
public class CustomTask1Listener implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
try{
// your business code goes here
} catch (Exception e) {
throw new ProcessEngineException("Error!!!");
}
}
}
If you prefer to explicitly model the error then you can attach error boundary event to the task and throw BpmnError from within the task listener
https://docs.camunda.org/manual/7.15/user-guide/process-engine/error-handling/#bpmn-2-0-error-event
https://docs.camunda.org/manual/7.15/user-guide/process-engine/delegation-code/#throw-bpmn-errors-from-delegation-code
1 Like
Thanks hassang for your answer. That’s resolve my issue.