Can an MSMQ queued messages survive a service/server restart? What I mean is that if a queue has messages and the server were to experience a hard restart, would the messages be still available in the queue after the restart?
To stop the MSMQ service Access the MQ_SERVER application class menu as described in Accessing KM menu commands. Choose KM Commands > Stop MSMQ Service. An information box appears which displays the current status of the MSMQ service. Click OK to close the information box.
Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline. Applications send messages to queues and read messages from queues.
To achieve this you have to mark the messages as Recoverable. By default, MSMQ messages are only held in memory, but Recoverable messages are backed to disk to enable reliable MSMQ Messaging.
using System.Messaging;
Message recoverableMessage = new Message();
recoverableMessage.Body = "Sample Recoverable Message";
recoverableMessage.Recoverable = true;
MessageQueue msgQ = new MessageQueue(@".\$private\Orders");
msgQ.Send(recoverableMessage);
There is an overview of this area at Reliable Messaging with MSMQ and .NET.
Transactional messages do not need to be manually marked as recoverable - this is implicit in the fact they are part of an MSMQ-based transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With