I have an existing system and am wondering if MSMQueue can retain value of queue if it restarts. It clears the value when I restart.
What is MSMQ? From Microsoft: Microsoft Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline. MSMQ provides guaranteed message delivery, efficient routing, security, and priority-based messaging.
Click Start and open Control Panel, Administrative Tools, and Computer Management. Open Services and Applications, Message Queuing, Message Queuing Triggers, and Rules. For each rule, open the Properties dialog, and select the Rule Action tab.
Message Queuing (MSMQ) 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.
If you do not restart the Message Queuing service, the disk storage usage remains at the peak requirement since the last restart of the Message Queuing service. Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method.
The MSMQOutgoingQueueManagement object defines the following properties. Returns the address for routing messages to the destination queue in the next hop. Returns the connection state of the outgoing queue.
Message Queuing provides guaranteed message delivery, efficient routing, security, and priority-based messaging. It can be used to implement solutions to both asynchronous and synchronous scenarios requiring high performance. The following list shows several places where Message Queuing can be used.
As paxdiablo writes MSMQ is a persistent queueing solution, but not by default! The default is to store messages in RAM and to have MSMQ to persist messages to disk so they are not lost in case of a server crash you have to specify it on EACH message.
More information on this can be found if you take a look at the property Message.Recoverable.
As @Kjell-Åke Gafvelin already said, you may configure each message, but the IMHO more convenient way would be to set it on the Queue itself.
MessageQueue msgQ = new MessageQueue(@".\private$\Orders");
msgQ.DefaultPropertiesToSend.Recoverable = true;
msgQ.Send("This message will be marked as Recoverable");
msgQ.Close();
From the article above (highlights by me):
By default, MSMQ stores some messages in memory for increased performance, and a message may be sent and received from a queue without ever having been written to disk.
Aditionally, you should make the queue transactional to guarantee the correct shipment and receiving of a message.
(Edit 2020-10-27: Removed link to external Microsoft post "Reliable messaging with MSMQ and .NET" as it is not available anymore.)
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