如果 Windows 服务停止,NserviceBus 是否完成消息处理?
我已将 nservicebus 程序安装为 Windows 服务。 当我停止 Windows 服务时,NserviceBus 是否会等待当前消息处理程序完成?
如果答案是否定的,那么我可能会完成一半的工作,并出现错误的状态(如果我的程序使用数据库)。
我做了一个实验 - 创建了一个程序,当它收到消息时执行 Thread.Sleep(100 * 1000) 。 当我在处理消息时停止 Windows 服务时,它会快速停止并且不会等待 100 秒。所以我认为答案是否定的。
如果答案是肯定的,请指出源代码中发生此类情况的位置。
I have nservicebus program installed as windows service.
When I stop windows service, does NserviceBus waits until current message handler is completed?
If the answer is no, then I may do a half of the work, and appear in incorrect state(if my program uses database).
I have done an experiment - created a program that does Thread.Sleep(100 * 1000) when it receives message.
When I stop windows service while message processing, it stops quickly and do not wait 100 seconds. So I assume that the answer is no.
If the answer is yes, please point me to the place in source code, where such stuff occurs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSB 不会等待,因此当前消息将回滚到队列中。所有处理程序都在事务中运行,因此不存在陷入不一致状态的风险。假设您的数据库已列入 dtc 事务中。如果不是,无论如何你都会不一致,所以所有的赌注都会失败。
NSB does not wait so the current message will rollback to the queue. All handlers are run in a transaction so there should be no risk to get in an inconsistent state. Assuming that your database is enlisted in the dtc transaction. If not you'll be inconsistent anyway so all bets are off.