What's the proper way to handle concurrency exceptions in EventStore?

377 Views Asked by At

Using JOliver EventStore 3.0 and reciving commands from NServiceBus, what's the proper way to handle concurrency exceptions? If I have more than one worker thread, this could be a common occurance.

Option 1

try
{
    // store the event
    ...
}
catch (ConcurrencyException)
{
    _bus.HandleCurrentMessageLater();
}

Option 2

Let it throw back to NServiceBus and get retried with the MsMqTransportConfig.MaxRetries option from the config.

Option 3

Something I'm not thinking of?

1

There are 1 best solutions below

1
On BEST ANSWER

You could compare the uncommitted events with the committed events and see if they actually conflict (according to your business rules) - if there's no conflicts then you can allow the events to be persisted, otherwise re-throw.

Generally though I just let it throw and have NServiceBus retry.