This is probably an obvious one but I'm having a little difficulty
working out how to do it due to my lack of experience with MSMQ (and
queueing systems in general).
I have a web application that publishes messages like OrderCreated and
OrderShipped that are consumed by a single service application. In
turn the consumers of these messages, after performing some
processing, publish SendEmail messages that are handled by the same
service application. The emails are then sent via a gmail account.
The problem that I am getting is that the SmtpClient sometimes throws
exceptions, mostly like due to fundamental problems with this
architecture (I'm not retrying emails, I'm not locking between the
consumer threads so only a single email can be sent at a time, and I
have a test service on the same server using the same account). Some
example exceptions are
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond
209.85.227.109:587
System.Net.Mail.SmtpException: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.5.1 Authentication Required.
I'm not really sure how to solve the architecture problems to make the
email more robust (any advice would be much appreciated!), but for a
temporary band-aid, how can I replay all the messages in the error
queue back in the main server queue?
Thanks,
Paul.