# Long running external REST Api call in the Service task

**URL:** <https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639>\
**Category:** Flowable Engine\
**Created:** [March 16, 2020, 11:29am UTC](https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639 "2020-03-16T11:29:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameer](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Ameer](https://forum.flowable.org/u/Ameer)\
**Post date:** [March 16, 2020, 11:29am UTC](https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639/1 "2020-03-16T11:29:44Z")

</div>

Hi Team,

I have 20+ service task. and i made all the service task “flowable:async=“true”” in BPMN.xml

so in my 10th service task, im calling(REST call) an external api it takes 8 mintues to execute and return the response back to service task.

once the response back , im getting FlowableOptimisticLockingException

(org.flowable.common.engine.api.FlowableOptimisticLockingException: Execution[id ‘09f7f5fd-676e-11ea-b9c2-0050568e1cce’] - activity ‘phase2-execute’ - parent ‘09f732a4-676e-11ea-b9c2-0050568e1cce’ was updated by another transaction concurrently)

but instead of going into next service task as per the sequence flow defined , it is trying the same service task again and again this is keep on going …

bpmn.xml as follows,

\< serviceTask id=“phase1” name=“phase1-execute”  
flowable:async=“true” flowable:delegateExpression="${phase1Service}" \>  
\< extensionElements\>  
flowable:failedJobRetryTimeCycle\>R1/PT1M\</flowable:failedJobRetryTimeCycle  
\< /extensionElements\>  
\< /serviceTask\>

\< sequenceFlow sourceRef=“phase1” targetRef=“phase2” /\>

\< serviceTask id=“phase2” name=“phase2-execute”  
flowable:async=“true” flowable:delegateExpression="${phase2Service}" \>  
\< extensionElements \>  
flowable:failedJobRetryTimeCycle\>R1/PT1M\</flowable:failedJobRetryTimeCycle  
\< /extensionElements\>  
\< /serviceTask\>

kindly help me to resolve this issue

---

<div class="post-metadata">

**Author:** ![wwitt](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wwitt/32/706_2.png) [@wwitt](https://forum.flowable.org/u/wwitt)\
**Post date:** [March 16, 2020, 2:21pm UTC](https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639/2 "2020-03-16T14:21:35Z")

</div>

Just to clarify, your issue is just with this single task?

I suspect you are running into the async executor’s 5 minute lock. The other async executors think the job has been killed without releasing the lock and start a new instance. [How to change the 5 minute timeout interval for a async job?](https://forum.flowable.org/t/how-to-change-the-5-minute-timeout-interval-for-a-async-job/2295/3)

You can either increase the timeout, to one that better meets your needs, or you can switch to using a triggerable service task and trigger the execution when the long running REST call returns.

---

<div class="post-metadata">

**Author:** ![Ameer](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Ameer](https://forum.flowable.org/u/Ameer)\
**Post date:** [March 16, 2020, 2:47pm UTC](https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639/3 "2020-03-16T14:47:58Z")

</div>

Thanks wwitt for the reply.

im facing this issue in total 3 of my service task out of 30.

is it possible to set this time out settings in spring external cofig file?  
i want it to be 15 minute

“flowable:  
process:  
async:  
executor:  
keep-alive-time: 15000  
or  
async-job-lock-time-in-millis: 900,000(15_60_1000)”

can i set this value like this? kindly correct me if im wrong

---

<div class="post-metadata">

**Author:** ![PHH](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/phh/32/94_2.png) [@PHH](https://forum.flowable.org/u/PHH)\
**Post date:** [March 16, 2020, 3:26pm UTC](https://forum.flowable.org/t/long-running-external-rest-api-call-in-the-service-task/5639/4 "2020-03-16T15:26:35Z")

</div>

With such a long wait, I wonder whether the problem might be better solved using events in some way rather that HTTP? Adds some complexity but gives a lot more control and scalability, I think.

Cheers  
Paul.
