I tried using enumerator. It behaved differtly in different scenarios Scenario 1 :
I had 1 million messages in a queue and a thread to count the number of messages, it gave me the exact result in 20 secs. Seconds Scenario 1 : I had 1 million messages in the queue and 30 worker threads which read from the queue and process the message and one thread to count the number of messages in the queue. The counter thread gave me some number after all the worker threads completed processing(more than 20 mins). This is my problem. I have a reader thred which keeps reading a record by record from a CSV file(having more than 5 millions of records) and sends to MSMQ and I have some 30 worker threads which keeps reading records one by one from MSMQ and process it. The problem is the reader thread can not keep sending millions of messages to MSMQ as there is a memory limit. I treid to send as mamy messages as possible to msmq. But after sending two and a half million messages, the MSMQ threw an error saying "Insufficient Memory". So I need to make reader thread sleep for some time once it sends a million messages and wake up after some time and start sending messages. Once it wakes up, I need to know the number of messages in the MSMQ so that It can send messages accordingle tp prevent from crossing the memory limit. Please let me know if anything could be done to solve this problem. -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Chris Day Sent: Wednesday, May 12, 2004 11:01 AM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] MSMQ I'm not sure if this works, and it is inefficient but call GetEnumerator() on the MessageQueue class then iterate though each message incrementing a counter, and voila you have the number of messages. I'm not sure if iterating is going to pull the messages off, or that it will be quick! If you just want to check if the queue is empty or not just do a Peek() with a timeout. HTH Chris > -----Original Message----- > From: Saravana Prasad S [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 12 May 2004 2:54 PM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] MSMQ > > Hi All, > > Is there anyway one can programatically know the number of > messages in a queue. I couldn't figure out any in System.Messaging > namespace. > > Thanks & Regards, > ------------------------------------------------------- > Saravana Prasad S > Software Engineer -Dell | Aries > > <<Picture (Metafile)>> > DELL, Global Development Center, India > Work: +91(80) 8419110/112 Ext: 77431 > Austin Ext: 78449 > ------------------------------------------------------- > > > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com Some > .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== This list is hosted by DevelopMentor(r) http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com