# Using CallActivity

**URL:** <https://forum.flowable.org/t/using-callactivity/2117>\
**Category:** Flowable Engine\
**Created:** [June 9, 2018, 1:58pm UTC](https://forum.flowable.org/t/using-callactivity/2117 "2018-06-09T13:58:44Z")\
**Posts on this page:** 1\
**Showing post:** 22

<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:** [June 26, 2018, 4:47am UTC](https://forum.flowable.org/t/using-callactivity/2117/22 "2018-06-26T04:47:25Z")

</div>

Hi Encho.

> [@enchobelezirev](#):
>
> But if I start a diagram which does not have CallActivity in it, the result is the same - I have a process which is not progressing at all.

When I run the test without CallActivity (without multiinstance, without async) execution works fine. If you want to resolve it create a jUnit test to know exactly where the problem is.

> [@enchobelezirev](#):
>
> Why is this OptimisticLockingException thrown

The optimistic locking exception which is thrown:

```auto
[flowable-async-job-executor-thread-2] ERROR org.flowable.job.service.impl.asyncexecutor.DefaultAsyncRunnableExecutionExceptionHandler - Job 50 failed
org.flowable.common.engine.api.FlowableOptimisticLockingException: HistoricVariableInstanceEntity[id=16, name=nrOfCompletedInstances, revision=0, type=integer, longValue=1, textValue=1] was updated by another transaction concurrently

```

The problem is that variable `nrOfCompletedInstances` is updated from each job. That’s why optimistic locking exception is thrown.  
Solution proposal:

1. Create async job in the loop. In that case you will avoid multiinstance behavior which is trying to update `nrOfCompletedInstances`
2. change callActivity to synchronous and multiinstance to sequential. The first task in the subprocess is asynchronous. What I would expect is that jobs are generated and job executors will execute them in parallel.

Regards  
Martin

---

_[View the full topic](https://forum.flowable.org/t/using-callactivity/2117)._
