Question about concurrent events and optimistic locking

Hi All:

Our application integrates with another application by having the external application send events via the rest api. On some of our user tasks we have multiple boundary events that look something like the following:

In some situations the external application can send both events at the same time. What I see is that this often (but not always) results in an optimistic locking exception. I have tried to address this by various combinations of setting the async and exclusive flag but it doesnt seem to help. I wrote a simple piece of node code that sends in 3 events at the same time and at least one rest call fails almost 100% of the time(it varies as to which one). So obviously we can address by telling the external app to implement retry logic to retry whatever events fail with optimistic locking exception, but is there anything that can be done on on the camunda side to mitigate this? Thanks in advance for any advice you can give

Yes, you are right.

I believe the only way to have the retry logic managed by the engine is to move the correlation logic to Camunda side so you can have a simple process taking care of correlation logic which is to be triggered by the external apps. This simple process consists of two events: a none start event and a dynamic throw message event. In which you need to tick async before check box of the throw message event so whenever throw message implementation fails, the engine does a retry as per the configuration.

But I personally prefer the 1st option as this makes things more complicated.