Click here to Skip to main content
15,943,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created a public queue and sent some messages to the queue using a windows service application. The sending application executes on the same server as the queue (i.e. this is a local queue).

After restarting the server, all of the queued messages were purged. Is there any way to persist these messages after a server restart?
Posted
Comments
Sergey Alexandrovich Kryukov 21-Mar-13 10:57am    
Why would you restart the service if some messages are not yet processed then?
—SA
saumil.sapariya 22-Mar-13 0:54am    
Services restarted Automatically when Application pools are recycled. plz have any suggestion? post on it. Thanks :)
Sergey Alexandrovich Kryukov 22-Mar-13 1:50am    
Well, a service handles some system events; including all cases when it is stopped. You can use it for completion of queue processing...
—SA
saumil.sapariya 22-Mar-13 6:19am    
Below Case (I noticed following case service restarted and first message lost-
(not reach a MSMQ queue))
1) When WCF Service Deploy at time first message send it lost.
2) When Service.svc file load at time message lost.
3) When Pool recycled at this time first message lost.

I received a message form queue it's separate thread it's continue running.
Prasad Khandekar 21-Mar-13 11:31am    
Please refer to this (http://msdn.microsoft.com/en-us/library/ms978430.aspx) libray article to know more about reliable messaging with MQ.

1 solution

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

Details can be found at the below link:-

http://msdn.microsoft.com/en-us/library/ms978430.aspx#bdadotnetasync2_topic2[^]
 
Share this answer
 
Comments
saumil.sapariya 22-Mar-13 9:23am    
I tried for this same code. I also set Message queue Acknowledge Property but Message Acknowledge gave send message true but message don't send to Queue (Message Lost).Acknowledge message or MSMQ trace also send a message to Particular Queue but Queue not receiver a message Is there any Error Or Exception?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900