Issue
I am using Axon with Spring boot and will like to list an event history for an aggregate.
With the event
store -> readEvents(String id)
, we only get events from the last snapshot.
eventStore.readEvents(aggregateId).asStream().map(e -> e.getpayload()).collect(Collectors.toList())
How can I read all the events for that aggregate since creation?
Solution
The EventStore
interface also exposes another method:
DomainEventStream readEvents(String aggregateIdentifier, long firstSequenceNumber)
You can use that one with a 0
as second parameter to force the Event Store to return all events starting from sequence 0, which is the very first event for an aggregate.
Answered By - Allard
Answer Checked By - Willingham (JavaFixing Volunteer)