问题描述
我正在使用事件存储区20.6.1.0
这个客户https://github.com/EventStore/EventStore-Client-NodeJS
当我将事件发布到事件存储并像这样在订阅者中确认时
const onEvent =
(event: ResolvedEvent,report: PersistentReport) => {
if (event.event) {
report.ack(event.event.id);
}
}
如果我从事件存储断开连接并再次重新连接,我会再次收到所有已确认的事件
为什么我收到已确认的事件,而不仅是新事件?
解决方法
创建持久连接时,必须设置最大检查点数。
就我而言,我发送的事件少于maxCheckpointCount
,并且在断开连接之前未确认它们。因此,重新连接后我又收到了它们。
await createPersistentSubscription(streamName,groupName)
.fromStart()
.enableLinkResolution()
.consumerStrategy(ROUND_ROBIN)
.maxCheckpointCount(1)
.minCheckpointCount(1)
.execute(connection)