如何防止 .NET 服务在等待依赖服务时超时
我有一个基于 C# 的服务,该服务依赖于 MSMQ 服务。 在某些场景下,MSMQ服务需要很长时间才能启动,显然会导致C#服务超时。 我怎样才能以编程方式解决这个问题?
编辑:看来我正在处理的错误报告不正确,该服务最终确实启动了。 对于造成的混乱,我深表歉意
I have a C# based service that is dependent on the MSMQ service. In some scenarios the MSMQ service takes a long time to start, apparently resulting in a timeout of the C# service. How can I fix this programatically?
Edit: It appears that the bug report I was working on was incorrect, the service does indeed start eventually. I apologize for the confusion
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,应该在单独的线程中等待队列,该线程应该直接在服务的 OnStart 方法中启动。
如果您这样做,启动命令就会成功,并且服务不会超时。
Normally waiting on a queue should be made in a separate thread, which should be started directly in the OnStart Method of the Service.
If you do it this way, the Start-command succeeds and the service will not time out.