"I restarted MSMQ and all my messages have vanished!"


This is one of those horrible surprises – the system has been working fine for months; someone needs to restart the machine; everything disappears! Developers notice that Transactional messages never disappear so it must be a problem with Non-Transactional messages…


The explanation is simple – the developer of the application wrote code to just create and send a message. The defaults mean you end up with Express messages which only exist in RAM and are not persisted to the disk, so cannot survive a restart. To be persisted, the Recoverable option must be selected when the message is created. Transactional messages, by design, automatically flip the Recoverable bit which is why they never disappear after a restart.


Here’s a simple table of the choices available:

















 


Non-Transactional


Transactional


Express (Non-Recoverable)


Yes


No


Recoverable


Yes


Yes


Express messages are also know as “fire-and-forget”. It doesn’t matter if they get lost as their value it low or they are easily replaced. A good example of something that may use them is a stock ticker – it doesn’t matter if one message gets lost as an updated stock price on the next message wil be along soon to replace it.


 


Here is a C# example from “Reliable Messaging with MSMQ and .NET” for setting the Recoverable property: 


Message recoverableMessage = new Message();
recoverableMessage.Body = “Sample Recoverable Message”;
recoverableMessage.Recoverable = true;
MessageQueue msgQ = new MessageQueue(@”.\$private\Orders”);
msgQ.Send(recoverableMessage);

Comments (2)

  1. Axl Weslowski says:

    > The defaults mean you end up with Express messages

    Well. The strange thing is, though. Using MQBench (MSMQBench.exe) on a non-transactional queue (I assume with the default settings) will only send/receive recoverable messages. How does one check if a queue, or MSMQ, or WCF, is set to express messages vs recoverable messages? FWIW I’m using MSMQ 3.0 on Windows Server 2003.

  2. MSDN Archive says:

    Hi Axl,

    MQWBench doesn’t have a default for message type. You have to specify message type in the command line (-se for sending express; -sr for sending recoverable; -s without a message type letter will not be accepted). If you add the -p parameter then you can see all the properties of the message you have just sent.

    The MQBench download includes the C++ source code for the application so you can check out how it works.

    "How does one check if a queue, or MSMQ, or WCF, is set to express messages vs recoverable messages?"

    This is set in the sending application as you are looking at a property of the message, not the destination queue.

    Cheers

    John Breakwell (MSFT)

Skip to main content