简体   繁体   English

如何在NServiceBus中正确合并多个消息?

[英]How do I correctly pool multiple message in NServiceBus?

I have an NServiceBus app which receives a particular message when a large database update is required. 我有一个NServiceBus应用程序,当需要大型数据库更新时会收到一条特定消息。 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? 我应该在其中放一个lock语句吗?

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. 在NServiceBus(App.config)的配置中,您可以设置NumberOfWorkerThreads,如果将其设置为1,则一次仅处理一条消息。

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. 但是正如Udi可能会说的那样,不要尝试从技术上解决问题,而是要从业务角度寻找解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM