cancel
Showing results for 
Search instead for 
Did you mean: 

Sychronous serviceTask exception handling

tomekzaremba
Champ in-the-making
Champ in-the-making
Hey,

I have following flow in my process:
1. Call serviceTask (via JavaDelegate)
2a. If all is ok take next step in process definition
2b. If exception occurs BpmnError is thrown and is catched by errorBoundaryEvent. Then flow goes to timer and after given amount of time serviceTask should be retried.

start —> serviceTask —> serviceTask2
                  ^             |
                  |              V
                  |      errorBoundary
                  |              |
                  |              V
                  —-      timer

But there is one problem - I can't specify max number of retries. I tried to specify repeat count in timer definition, but each this did't work.

I saw that async tasks can set maxNoOfRetries, but in my case I can't switch from sync to async (next step must be executed only if previous was successfully completed).

In docs I didn't find any built-in mechanism description for my case. I have idea for one dirty solution - saving execution variable with failures count, but I won't be proud of that.

Any help or hint will be appreciated.
3 REPLIES 3

trademak
Star Contributor
Star Contributor
What you have build is quite similar to what you get with an async job out-of-the-box. Service task 2 will only be executed when the service task 1 job is completed successfully. So maybe you can explain a bit more why you can't use an async service task?

Best regards,

tomekzaremba
Champ in-the-making
Champ in-the-making
I misunderstood async job concept - it is more than acceptable in my use case. But switching service tasks to be asynchronous caused fail of my integration tests - to be green again I had to add Thread.sleep calls in my tests (wait for async task to end).

I tried to disable asyncExecutorActive in process engine configuration but that caused that none process instance job was started. Have you got any solution for that?

jbarrez
Star Contributor
Star Contributor
In our unit tests, there is a method 'waitForAllJobsToBeExecuted' that does what you need without sleeps.