Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSMQ - can a queue survive a queue process restart/server restart

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?

like image 430
Moiz Tankiwala Avatar asked Oct 11 '10 12:10

Moiz Tankiwala


People also ask

How do I stop MSMQ service?

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.

What is MSMQ used for?

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.


1 Answers

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.

like image 66
Steve Townsend Avatar answered Oct 14 '22 12:10

Steve Townsend