Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is causing EventStore to throw ConcurrencyException so easily?
    text
    copied!<p>Using <a href="http://github.com/joliver/EventStore" rel="nofollow">JOliver EventStore</a> 3.0, and just getting started with simple samples.</p> <p>I have a simple pub/sub CQRS implementation using NServiceBus. A client sends commands on the bus, a domain server recieves and processes the commands and stores events to the eventstore, which are then published on the bus by the eventstore's dispatcher. a read-model server then subscribes to those events to update the read-model. Nothing fancy, pretty much by-the-book.</p> <p>It is working, but just in simple tests I am getting lots of concurrency exceptions (intermittantly) on the domain server when the event is stored to the EventStore. It properly retries, but sometimes it hits the 5 retry limit and the command ends up on the error queue.</p> <p>Where could I start investigating to see what is causing the concurrency exception? I remove the dispatcher and just focus on storing events and it has the same issue.</p> <p>I'm using RavenDB for persistence of my EventStore. I'm not doing anything fancy, just this:</p> <pre class="lang-cs prettyprint-override"><code>using (var stream = eventStore.OpenStream(entityId, 0, int.MaxValue)) { stream.Add(new EventMessage { Body = myEvent }); stream.CommitChanges(Guid.NewGuid()); } </code></pre> <p>The stack trace for the exception looks like this:</p> <blockquote> <p>2012-03-17 18:34:01,166 [Worker.14] WARN NServiceBus.Unicast.UnicastBus [(null)] &lt;(null)> - EmployeeCommandHandler failed handling message. EventStore.ConcurrencyException: Exception of type 'EventStore.ConcurrencyException' was thrown. at EventStore.OptimisticPipelineHook.PreCommit(Commit attempt) in c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticPipelineHook.cs:line 55 at EventStore.OptimisticEventStore.Commit(Commit attempt) in c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStore.cs:line 90 at EventStore.OptimisticEventStream.PersistChanges(Guid commitId) in c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStream.cs:line 168 at EventStore.OptimisticEventStream.CommitChanges(Guid commitId) in c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStream.cs:line 149 at CQRSTest3.Domain.Extensions.StoreEvent(IStoreEvents eventStore, Guid entityId, Object evt) in C:\dev\test\CQRSTest3\CQRSTest3.Domain\Extensions.cs:line 13 at CQRSTest3.Domain.ComandHandlers.EmployeeCommandHandler.Handle(ChangeEmployeeSalary message) in C:\dev\test\CQRSTest3\CQRSTest3.Domain\ComandHandlers\Emplo yeeCommandHandler.cs:line 55</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload