Paul, I think it all boils down to having too many messages received in that queue. If they are not all intended for one application (and from your need to iterate thru them it seems like so) I would suggest using multiple incoming queues (each application with its own queue) so that the volume of messages that you need to search through is not that big. Also, try to play with the priority of the message. If you set it to "Highest", the message should be placed towards the beginning of the list and both PeekBy and ReceiveBy methods should return faster.
Good luck, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Paul Cowan Sent: Sunday, September 03, 2006 4:51 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] MSMQ ReceiveByCorrelationId Hi all, I am having trouble with a bit of MSMQ functionality that sends messages from an ASP.NET web application. Every MSMQ send message that is sent has a corresponding receive MSMQ message. Obviously sending the messages are straightforward but receiving them is proving very slow, I have the following method that takes care of receiving the messages: private XmlReader ReceiveMessage(string messageId) { _receiveQ = GetQueue(LawConfig.MSMQ.ReceiveMSMQ); Message message = null; while (_receiveQ.PeekByCorrelationId(messageId, _timeOut) != null) { message = _receiveQ.ReceiveByCorrelationId(messageId, _timeOut); if (message != null) break; } if (message == null) throw new Exception("No message in the receive queue."); XmlReader reader = GetXmlReader(message); return reader; } The ReceiveByCorrelationId seems very unefficient as from what I can gather, it iterates all the messages from the queue until it finds the correct message. Is there a more efficient way of handling this? =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com