spartan712
spartan712

Reputation: 37

Axon Event Store Handling - Read All events for an aggregate

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?

Upvotes: 2

Views: 911

Answers (1)

Allard
Allard

Reputation: 2890

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.

Upvotes: 4

Related Questions