When I try to save the events to the store I get the following exception:
The commit must be uniquely identified.\r\nParameter name: attempt
But my code always generates a new New Guid for the commit (as per NEventStore example)
public void Save(Guid aggregateId, IEnumerable<Event> events, int expectedVersion)
{
var eventList = events as IList<Event> ?? events.ToList();
using (var scope = new TransactionScope())
using (var stream = store.OpenStream(aggregateId, 0, int.MaxValue))
{
if(stream.StreamRevision != expectedVersion)
throw new ConcurrencyException();
foreach (var @event in eventList)
{
stream.Add(new EventMessage { Body = @event });
}
stream.CommitChanges(Guid.NewGuid());
scope.Complete();
}
foreach (var @event in eventList)
{
publisher.Publish(@event);
}
}
Does anyone have any idea why this is happening?
The message is misleading. It is thrown here when this check...
Is false. So it should say: both the
CommitId
andStreamId
must not be empty.