Hi everyone,
After reading the docs and approaching to EventSourcing theory, I’m trying to implement a very simple PoC with EventStoreDB and Spring Boot.
My first trouble is using the com.eventstore.dbclient.EventData wrapper class.
Suppose having an Event with this structure:
{
"id": "a22f823d-1a5s-1432-aed5-032805c8410d",
"type": "ORDER-PLACED",
"streamId": "1", // The order-id
"streamPosition": 1, // The event position in the stream
"timestamp": "2023-12-05T00:00:12.000Z",
"body": {
.... // The Order Data
},
"metadata":
{
.... // The Event Metadata
}
}
Is it right to pass an event having the given structure (MyEvent in the example below) as eventData of the builderAsJson?
EventData eventData = EventData
.builderAsJson(
THE-EVENT-UUID,
THE-EVENT-TYPE,
new MyEvent())
.build();
Or, alternatively, is it better to reduce the Event structure only to the Body?
It seems to me that using the first approach leads to duplicating the event’s data (event-id, event-type, event-metadata) that is passed both directly to the builderAsJson builder and as MyEvent data)
What is the right approach?
Thank you