NServiceBus Sagas - 至少一次交付
将 NServiceBus 与 NHibernate saga persister 结合使用,当可能多次接收消息时,如何避免重复的 sagas?
以下是我到目前为止想到的一些解决方案:
永远不要调用 MarkAsComplete(),这样重复数据删除是由传奇本身以通常的方式处理的。
实现我自己的saga持久器,它存储已完成saga的相关ID,因此重复/附加消息将被忽略。
Using NServiceBus with the NHibernate saga persister, how can I avoid duplicate sagas when it's possible for a message to be received more than once?
Here are some solutions that I've thought of so far:
Never call MarkAsComplete() so the deduplication is handled in the usual fashion by the saga itself.
Implement my own saga persister which stores the correlation ids for completed sagas so duplicate/additional messages are ignored.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是什么会导致消息被多次接收 - 是否是由于重试同一条消息(例如数据库中存在死锁的情况)?这些类型的重试(导致同一消息被“处理”多次)已经由 NServiceBus 的事务性质处理。
如果这种情况是由于其他端点多次发送消息造成的,建议您看看可以采取哪些措施来防止发送端发生这种情况。如果这是不可能的,那么是的,一个永远不会完成的传奇故事可以作为你的过滤器。
The question is what would cause the message to be received multiple times - is it due to retries of the same message (like in the case where there was a deadlock in the DB)? Those kinds of retries (causing the same message to be "processed" multiple times) are already handled by the transactional nature of NServiceBus.
If the situation is due to the message being sent by some other endpoint multiple times, the recommendation would be to see what you could do to prevent that on the sending side. If that isn't possible, then yes, a saga that doesn't ever complete could serve as your filter.