2

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?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575

1 Answers1

3

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.

Elliot Ritchie
  • 417
  • 3
  • 5
  • Is this something the command handler can retry if it is responsible for saving to the event store? Or should the entire command handle throw and reverse the transaction?? – Elliot Wood Apr 23 '14 at 07:34