Can MSMQueue retain their value when the Windows restart?
Asked Answered
G

3

5

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.

Gerladina answered 24/2, 2012 at 5:55 Comment(0)
G
8

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.

Glass answered 24/2, 2012 at 9:15 Comment(0)
A
8

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.)

Accentuation answered 24/2, 2012 at 10:31 Comment(3)
Please note that the article is not 100% accurate. "Why are my Express MSMQ messages being written to disk?" blogs.msdn.com/b/johnbreakwell/archive/2008/04/04/…Armin
Thank you @John for the additional info. Fundamentals shaken. :-)Accentuation
Thank you, @Joel. I removed the link. It seems like Microsoft cleaned up old pages. John's like is broken as well. I'm glad I quoted the important parts here for reference.Accentuation
C
0

Yes, MSMQ is a persistent queueing solution. It stores messages securely on backing storage that will not be affected by loss of power (unless you experience things like the disk blowing apart from a truly massive power surge of course).

Its whole point is to provide reliable queueing of messages in a potentially unreliable environment. To that end, losing messages when a particular server went down would be a considerable disadvantage.

From Microsoft's own pages (and apologies for the sales-pitch-like language):

Message Queuing applications can use the Message Queuing infrastructure to communicate across heterogeneous networks and with computers that may be offline. Message Queuing provides guaranteed message delivery, efficient routing, security, transaction support, and priority-based messaging.

Conform answered 24/2, 2012 at 5:56 Comment(1)
I think that the 'guaranteed message delivery' is referencing rather to the transactional functionality of the queues. Of course, persisting them in a fail safe manner will be a necessary part of it. :-). But that is, however, NOT by default.Accentuation

© 2022 - 2024 — McMap. All rights reserved.