java为什么选择事件源模式中的事件流?
我想确保我对随机剥离东西有清晰的认识
事件存储数据库
| p_key | invoice_id | Event type | Version | Data |
|-------|------------|-------------------|---------|------|
| 1 | 41234 | Invoice_Generated | 1 | JSON |
| 2 | 34241 | Invoice_Generated | 1 | JSON |
| 3 | 12345 | Invoice_Generated | 1 | JSON |
| 4 | 12345 | Invoice_Reviewed | 2 | JSON |
| 5 | 12345 | Invoice_Paid | 3 | JSON |
JAVA端组件
- 活动商店:
- 事件流
- 事件
事件存储区负责检索事件列表,并在完成所有操作后将事件保存到数据库中
public interface EventStore {
EventStream loadEventStream(AggregateId aggregateId);
void store(AggregateId aggregateId, long version, List<Event> events);
}
事件本质上是从数据库检索到的行之一
public interface Event<T> {
AggregateId getAggregateId();
int getVersion();
String getEventType();
void applyOn(T account);
}
我没有得到的是事件流的使用。我不明白为什么我需要一个事件流
public interface EventStream extends Iterable<Event> {
long version();
void addAll(List<Event> changes);
}
事件流的唯一目的是让我能够迭代一系列听起来不那么有用的事件吗?也许我遗漏了一些东西,但为什么我不能摆脱事件流,结束这一天呢
共 (0) 个答案