2

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?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
spartan712
  • 37
  • 5

1 Answers1

3

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.

Allard
  • 2,640
  • 13
  • 13
  • Thanks @Allard it worked, I was just looking at the default method in the interface instead of the implementation class that overrides it(AbstractEventStore). – spartan712 Oct 26 '21 at 14:57