如何在 NServiceBus 中正确池化多个消息?
我有一个 NServiceBus 应用程序,当需要大型数据库更新时,它会收到特定消息。在进行此更新时,我想以某种方式忽略此类类型的所有传入消息。最好的方法是什么?我应该在其中添加 lock
语句吗?
I have an NServiceBus app which receives a particular message when a large database update is required. While this update is happening, I want to either somehow ignore all incoming messages of this type. What is the best way of doing it? Should I put a lock
statement in there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 NServiceBus (App.config) 的配置中,您可以设置 NumberOfWorkerThreads,如果将其设置为 1,则一次只会处理一条消息。
然后,如果您将停止处理此消息的时间保留在内存中。您可以删除这两个时间之间到达的所有邮件。
但正如 Udi 可能会说的那样,不要尝试从技术上解决问题,而是从业务角度寻找解决方案。
In the config of NServiceBus (App.config) you can set the NumberOfWorkerThreads, if you set this to 1 only one message at a time will be processed.
Then if you keep the time you stopped processing this message in memory. You can drop all messages that have arrived between these two times.
But as Udi probably would say, don't try to solve it technically but find a solution from the business perspective.