Hello,
This maybe a stupid question but I’m pretty new to event sourcing and cqrs but as part of my R&D for my new project I have a question regarding deterministic ID’s for my events and commands.
Up until now I have been using Guid.NewGuid() in C# to just generate random id’s for the events/commands.
After recent reading though it seems that to cover event idempotence using GES I would need to use a deterministic id as well as the expected version.
I already have the expected version implemented and that is working well; with the event ID I have replaced Guid.NewGuid() with this inside my eventstore repo :-
private Guid ToDeterministic(IEvent e)
{
return GuidUtility.Create(Guids.SystemNamespace, $"{typeof(TAggregate).Name}-{e.AggregateId}-{e.Version}");
}
``
The guid utility class is from here: https://code.logos.com/blog/2011/04/generating_a_deterministic_guid.html
Is this the correct way to implement this or have I miss-understood something?
Could/should the guid namespace be the system or should it be more granular e.g, sub-domain/aggregate?
I’m assuming this would apply to commands also?
Thanks in advance,
Rick.