如何在 nservicebus MSMQ 中达到最大重试次数时发送电子邮件
我有一个处理消息的 .net 服务。对于任何失败,我使用 log4net 并写入文件。我为此添加了一个 SMTP 附加程序。问题是当出现问题时我只想发送一封电子邮件。我的 app.config 中的 MaxRetries 设置为 5,这是正确的,log4net 文件中记录了 5 个错误,但也发送了 5 封电子邮件。
有什么方法可以控制最大重试次数并在达到最大重试次数时触发我的电子邮件吗?
感谢您的帮助。
I have a .net service that processes messages. For any failures, i use log4net and write to a file. I added an SMTP appender for this. The issue is that I only want to send one email when something goes wrong. The MaxRetries in my app.config is set to 5 and this is correct, 5 errors are logged in the log4net file but 5 emails are also sent.
Is there some way I can get a handle on the max retries and fire my email when that is reached?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加从错误队列中读取的常规 nservicebus 端点。为 IMessage 添加一个处理程序,并在该处理程序中添加对 smtpclient.send 的调用。
我有一篇文章试图解释可能感兴趣的基于消息的系统的错误处理:
http://andreasohlund.net/2010/03 /15/errorhandling-in-a-message-orient-world/
Hoep 这有帮助!
Add a regular nservicebus endpoint that reads from the error queue. Add a handler for IMessage and within that handler add a call to smtpclient.send.
I have a post that tries to explain error handling for message based systems that might be of interest:
http://andreasohlund.net/2010/03/15/errorhandling-in-a-message-oriented-world/
Hoep this helps!