cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid multiple calls with the same processInstanceId

rufini
Champ in-the-making
Champ in-the-making
Hi

I would like to know if Activiti can help me to block a second call with the same processInstanceId while a serviceTask is running.

Scenario: a web user retrying with the same processInstanceId while processing the previous request. (I've no control over UI)

Can Activiti help me to fix this, or should I do it manually?

Thanks!
2 REPLIES 2

heymjo
Champ on-the-rise
Champ on-the-rise
'blocking a second call' can mean just about anything, but IMO process concurrency (or restrictions thereof) should be modelled outside of the business process.

If you really must model it inside the process then you might be able to use an executionlistener on the start event of the process, and throw an exception or something when you detect that another instance of the same process is running.

frederikherema1
Star Contributor
Star Contributor
Activiti has optimistic locking in place. In case two threads concurrently eg. complete the same task on a process-instance, one of them will get a "org.activiti.engine.ActivitiOptimisticLockingException". Your logic, consuming the Activiti API, can catch this and handle accordingly.