如何合并 NServiceBus 中相关事件的处理?
我遇到的情况是,我有一个服务订阅事件消息并在事件消息到达时执行一些工作。有一类事件可能会在引用相同基础数据的许多事件的短时间内突发到达。我希望能够将相关事件的处理推迟一小段时间,以便我只为每批相关事件进行一次计算,而不是响应每个单独的事件。是否有某种我可以遵循的模式,可以让我在一段时间内收集相关事件,然后一次性处理它们?我在想传奇+超时可能能够实现这一点,但不确定这是否合适。
谢谢!
I have a situation where I have a service subscribing to event messages and performing some work when they arrive. There is a certain class of events which can arrive in short bursts of many events which reference the same underlying data. I would like to be able to defer processing of related events for a short period of time, so that I only do the calculation once for each batch of related events, rather than in response to each individual event. Is there some kind of pattern I can follow which will allow me to collect related events for a period of time and then process them all at once? I was thinking a saga + timeout might be able to achieve this, but not sure if this is an appropriate use for that.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,saga 可能是一种可行的方法 - 但是请考虑 saga 持久性的性能(当前版本中的 NHibernate,下一个版本中的 RavenDB)与您的容错需求(如果机器崩溃,将丢失一些消息是可以接受的)。
恐怕没有简单的答案。
Yes, a saga could be the way to go - however consider the performance of the saga persistence (NHibernate over a DB in the current version, RavenDB in the next version) as compared to your fault-tolerance needs (if a machine crashes, would it be acceptable to lose some messages).
No easy answers, I'm afraid.