[英]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.我正在将 Axon 与 Spring boot 一起使用,并希望列出聚合的事件历史记录。 With the
event
store -> readEvents(String id)
, we only get events from the last snapshot.使用
event
store -> readEvents(String id)
,我们只能从最后一个快照中获取事件。
eventStore.readEvents(aggregateId).asStream().map(e -> e.getpayload()).collect(Collectors.toList())
How can I read all the events for that aggregate since creation?自创建以来,如何读取该聚合的所有事件?
The EventStore
interface also exposes another method: EventStore
接口还公开了另一个方法:
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.您可以使用带有
0
第二个参数来强制事件存储返回从序列 0 开始的所有事件,这是聚合的第一个事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.