I have a local MessageQueue with sender and receiver being in the same application (a delayed-start Windows service using .NET Framework 4.0). An asynchronous read is always pending on the queue, reissued after every completed read or read failure. Typically, a message is placed in the queue and immediately read from the queue to continue the associated activity. It uses very basic operations and all default settings, essentially:
MessageQueue myMQ = new MessageQueue(path);
myMQ.ReceiveCompleted += ReceiveCompletedHandler;
myMQ.BeginReceive();
myMQ.Send(new Message(messageBodyObject));
From the application's logged information, I have evidence of an instance where a message was successfully delivered through the queue, but an identical message sent three hours later seems to have never gotten into the queue. Multiple attempts were made, making multiple calls to
MessageQueue.Send(msg)
, and the pending read was never triggered, nor was the Message seen waiting in the queue (which would indicate that the reads had stopped).
Making matters worse, this error condition persisted through a computer reboot. Terminating and restarting the service application after the reboot finally cleared the condition and everything resumed working as expected.
This has not been seen before, but it could be a critical issue if it happens again so I have to at least be able to detect it. But how can you detect an error that doesn't leave evidence of its occurrence? If I knew what conditions might cause
Send(msg)
to fail silently, I might be able find a way to detect it. Right now, though, I am clueless.
What I have tried:
I found a related issue that existed in an older version of MSMQ, but that shouldn't apply in current versions. Most forum posts I found on lost messages were related to remote queues and IP addresses, which doesn't apply here since this is a local queue.
This post[
^] on StackOverflow hints that the message might end up some place other than the intended local queue, but MSDN asserts
here[
^] that "If the queue is local, the message always reaches the queue." That seems to create a contradiction I don't know how to resolve.