Reputation: 979
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?
Upvotes: 0
Views: 150
Reputation: 979
The message is misleading. It is thrown here when this check...
attempt.StreamId != Guid.Empty && attempt.CommitId != Guid.Empty
Is false. So it should say: both the CommitId
and StreamId
must not be empty.
Upvotes: 1