Replaying the MSMQ error queue

311 views
Skip to first unread message

Paul Cox

unread,
Jan 25, 2011, 5:58:40 AM1/25/11
to masstransit-discuss
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.

Chris Patterson

unread,
Jan 25, 2011, 8:50:07 AM1/25/11
to masstrans...@googlegroups.com
There is a BusDriver utility under tools that can copy raw messages between queues, that should get you started.

As for your architecture, you could model the send e-mail process as a saga, and track the state of the delivery, keep track of retries, etc.

You could also ratchet down the thread count by adjusting the ConcurrentConsumerLimit down to 1 to make troubleshooting easier.

> --
> You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
> To post to this group, send email to masstrans...@googlegroups.com.
> To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.
>

Paul Cox

unread,
Jan 25, 2011, 10:43:12 AM1/25/11
to masstransit-discuss
Thank Chris just what I needed for moving the messages.

Is it safe to call the MoveN command with a high value, rather than
calling Move for each individual message, or do I risk losing messages
this way?
Reply all
Reply to author
Forward
0 new messages