-1

Problem: Service task (which calls API) is invoked twice with OptimisticLockingException Case: I have two sub processes and all service task calling Api’s and subprocesses are set to async before ‘true’ but got OptimisticLockingException. also the same service task gets invoked twice before proceeding to next service task in sequence, when this happens the response from API received as part of the first invocation of serice task in not persisted in the DB and the response of 2nd API call is persisted.

I am trying to resolve that by exclusive true my service tasks are running sequentially across the sub processes. Now I want to run my sub processes in parallel with single invocation of same service task within the sub process.

1 Answers1

0

If you want to avoid that the service task gets executed a second time in case of a rollback (triggered e.g. by an OLE), try setting async after the service task. However, thsi is not required if it is followed by an async before on a subsequent parallel gateway.

To handle OLEs the best practice is to set an async before on the parallel gateway. See https://docs.camunda.io/docs/components/best-practices/development/understanding-transaction-handling-c7/

"Do configure a savepoint before [...] Parallel joins Parallel Join Inclusive Join Multiinstance Task: Parallel joins synchronize separate process pathes, which is why one of two path executions arriving at a parallel join at the same time will be rolled back with an optimistic locking exception and must be retryed later on. Therefore such a savepoint makes sure that the path synchronisation will be taken care of by Camunda's internal job executor. Note that for multi instance activities, there exists a dedicated "multi instance asynchronous after" flag which saves every single instance of those multiple instances directly after their execution, hence still "before" their technical synchronization."

rob2universe
  • 7,059
  • 39
  • 54