如何在 nservicebus MSMQ 中达到最大重试次数时发送电子邮件

发布于 2024-09-01 02:18:36 字数 226 浏览 1 评论 0原文

我有一个处理消息的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-09-08 02:18:36

添加从错误队列中读取的常规 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文