Where should the ID of an event be stored

Hi,

Following my last query, I am also thinking about whether I should have an ID on an event.

If this is a good practice, should it be stored on the event or within the metadata.

Any thoughts welcome.

Kind regards

Sean.

there is already an identifer on an event. there is no reason to have two

Greg,

Aren’t those built-in event IDs meant more as commit IDs, and have more to do with idempotent write control than individual business event identification?

It strikes me that any unique id you generate should do. The idempotency comes into play when you try to push the same event again (say, through supplying the same event id). Can’t imagine a case where one would need to identify events twice. Also, you will not get the idempotency guarantees on your “second” id. So you may, inadvertently submit an event twice (with different ES event id, but same business logic id).

Forgive me if I don’t know what I’m talking about.

The exception with event IDs I was thinking about is when an event is
posted with an ID that already exists but the expected version number
is different than the original event.

My understanding is that in such a case, a new event is written with
the same ID as the previous event. Is such a case, the ID provided by
the store _may_ not have the same meaning of "unique" as a unique
business identifier.

To the original question of providing unique IDs for events, it would
seem to be a question of whether the events need to be uniquely
identified from a business perspective, and whether the built-in event
IDs are sufficient to that purpose.

Arguably, an event can be posted with the same built-in ID, but with
different payloads, where part of the payload is a unique business
operation ID.

I found the answers provided to the original question to be ambiguous.

If a recorded business operation needs to be uniquely identified, it
would seem that an ID should be provided as part of the event data,
rather than depending on the built-in IDs.

-Scott

Why are you writing the same conceptual identifier to multiple places?
I see some use cases this could happen on but they are odd. There is
nothing precluding the idea of another unique identifier.

I guess the point I was making is that it appears that the original question addressed a quandary over whether to use EventStore’s event IDs as business identifiers, versus providing identifiers as part of the payload.

Maybe I misunderstood or misinterpreted the original question.