Process expression delegate one at a time

Hello!

I’ve ran into a problem with camunda process and I’ve currently thought of an idea what could fix my issue.

My issue is that i have bunch of payments coming in and they are processed by a java class. There can be a case multiple payments can go same account at the same time. The process itself throws up a lock on database row causing all the other process instances to fail and one to pass

What I’ve tried
Set a retry for Retry Time Cycle for R100/PT10S however as one process is locking, the others are trying to lock aswell causing everyone to fail

So what I’ve thought is maybe it possible to make it like this that specific java class processes only 1 process instance at a time and takes next one when finished. However I’m not quite sure how to achieve that or are there any other viable solutions?

I’ve also looked into this thread here

however if i understand correctly it’ll just block the other instances from running?

Currently using Spring Boot 1.5.12 and camunda 7.6

Thanks forward

Hi @Sarrea,

Wouldn’t using an asyncBefore on the Service Task the processes the payments solve your issue?

This would create a Job for each payment. Then, the Job executor will pick up and execute the jobs. If a job fails, it will be retried several times (you will need to specify the number of retries).

Best,
Nikola

I have set it to asyncBefore. All the payments come in precisely at the same time. so all the job retry at the same time as well causing all the jobs except for one to fail. If i retry them manually one by one then yes they pass

Where is the database lock occurring ?
The Camunda db is locking? If so, can you explain what is unique that is locking?
Why is receiving multiple payments for a single account locking?
If you receiving payments for different accounts at the same time, would this cause the same issue?

If you have a generic “process payment” Bpmn, then you if you are receiving a bunch of Start events at the same time, you need to have your process check for other concurrent active processes and essentially go into a retry loop.

Hey

it is not camunda db locking but the service’s own database lock. This account’s locking has implemented before my times and when asked about it, answer was that it was to avoid deadlocks. This does not happen there are many payments coming that are all going to different accounts. Only if payments come in to one account

A simple fix for this would be to set async on the start event so when the process starts you are saving some Variables, one of which would be your account id. Then you have a task that checks if there is another active process, if yes you have a timer that waits 1 min and then loops back to trying again.