node.js - 重新连接到 EventStore 中的持久连接后不重复确认的事件
问题描述
我正在使用 Eventstore20.6.1.0
而这个客户端https://github.com/EventStore/EventStore-Client-NodeJS
当我将事件发布到 eventstore 并像这样在订阅者中确认它们时
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)
推荐阅读
- sql - SQL Server:SELECT 查询以获取 DISTINCT 和 MAX 显示顺序值
- python - Beautifulsoup For 循环只打印了几个
- c# - 对象到 IEnumerable
- bigdata - 如何在某种时间线上可视化并发事件数据
- python - Latex:列表不能正确替换特殊字符
- xcode - 由于xcode,无法在mac上使用python
- python - 使用 Pandas 和 Python 操作分层数据集
- c - 启用外部中断 ARM Cortex-M0+ (STM32G070)
- gradle - 是否可以强制 Gradle 降级具有特定扩展名的某些依赖项的版本
- javascript - React.js - 收到错误“渲染没有返回任何内容。” 从 switch 语句