# Service tasks are executed multiple times

**URL:** <https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111>\
**Category:** Flowable Engine\
**Created:** [December 21, 2018, 3:04pm UTC](https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111 "2018-12-21T15:04:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonovdenis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/simonovdenis/32/732_2.png) [@simonovdenis](https://forum.flowable.org/u/simonovdenis)\
**Post date:** [December 21, 2018, 3:04pm UTC](https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111/1 "2018-12-21T15:04:56Z")

</div>

Hello All.

Maybe it is the known issue - I have multiple service tasks in process, which are supposed to be called one by one. The issue is, that some of them are called multiple times. To be more presize - I have 3 service tasks, first one is called 1 time, second one is called 3 times, third task is called 2 times(I can see it in debug). Simplified process looks so:

```
<startEvent id="start"/>

<sequenceFlow sourceRef="start" targetRef="firstServiceTask" />

<serviceTask id="firstServiceTask" name="First Service Task"
             flowable:delegateExpression="${firstJavaDelegateSpringBean}" />

<sequenceFlow sourceRef="firstServiceTask" targetRef="secondServiceTask" />

<serviceTask id="secondServiceTask" name="Second Service Task"
             flowable:delegateExpression="${secondJavaDelegateSpringBean}"/>

<sequenceFlow sourceRef="secondServiceTask" targetRef="thirdServiceTask"/>

<serviceTask id="thirdServiceTask" name="Schedule Auction Specification Event Action"
             flowable:delegateExpression="${thirdJavaDelegateSpringBean}"/>

<sequenceFlow sourceRef="thirdServiceTask" targetRef="end"/>

<endEvent id="end"/>

```

Have you ever faced similar behavior? how did you solve it for yourself?

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [December 21, 2018, 4:17pm UTC](https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111/2 "2018-12-21T16:17:53Z")

</div>

Hi,

that is really strange. There are plenty of tests testing sequence flows. I would not expect such as behaviour with the default engine configuration. Could you share simple jUnit test for it please?

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![arpit.agrawal](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@arpit.agrawal](https://forum.flowable.org/u/arpit.agrawal)\
**Post date:** [January 3, 2019, 3:41pm UTC](https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111/3 "2019-01-03T15:41:16Z")

</div>

Hi,

Can it be due to service tasks throwing error(not logged properly) and executor retrying those service task?

Thank You,

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [January 7, 2019, 7:02am UTC](https://forum.flowable.org/t/service-tasks-are-executed-multiple-times/3111/4 "2019-01-07T07:02:59Z")

</div>

Hey @arpit.agrawal,

Yes it can be due to the throwing of an error. The BPMN you provided doesn’t seem to show that a service task is marked as async. However, if it is and then an exception is thrown during the execution of the 2nd service task the transaction would be rollbacked and then the async executor would retry it again and the 1st service task would be executed again
