Gilbert
Gilbert

Reputation: 187

how to send email when maxretries reached in nservicebus MSMQ

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.

Upvotes: 3

Views: 1022

Answers (1)

Andreas Öhlund
Andreas Öhlund

Reputation: 5273

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!

Upvotes: 5

Related Questions