private void SendToErrorQueue(Message message, MessageQueueTransaction transaction, Exception exception)
{
if (message == null)
return;
if (exception != null)
_logger.ErrorException(String.Format("Message {0} was handled maximum number of times and moved to the error queue. ",
message.Label), exception);
// Open the queue.
using (var queue = new MessageQueue(_errorQueue.GetQueueLocalName()))
{
// Set the formatter to JSON.
queue.Formatter = new MsmqMessageFormatter();
message.Formatter = new MsmqMessageFormatter();
// Send the message.
queue.Send(message, transaction);
}
}