dcsimg
Results 1 to 3 of 3

Thread: Oldest MSMQ message

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2013
    Posts
    43

    Oldest MSMQ message

    Hi Guys,

    I want to write something to return the date of oldest messages in all MSMQ queues on a box. Looking at examples it seems to me the easiest way to do this is to use the MSMQ com object to iterate through the entire queue and save the oldest date by priority. Does this make sense or is there an easier way to do this? I am a little concerned of the performance implication of iterating through a very large queue.

    I see that out of the box WMI cannot do this but I found a 3rd party WMI class that seems to be capable however I am always unsure about including stuff I cannot fix or get support for in my projects.

    thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,371

    Re: Oldest MSMQ message

    PeekCurrent/PeekNext to work your way through may be the best option available.

    It sounds like you only need the header so call with WantDestinationQueue := False, WantBody := False, ReceiveTimeout := 1 (since you are not waiting for message arrivals and probably don't want to hit a 2 hour wait if communication fails), WantConnectorType := False. See the docs for default values, these are all optional parameters.

    The returned Message objects should have values for MSMQMessage.ArrivedTime, MSMQMessage.Priority, and other properties of interest to you.


    I'm not aware of anything faster.

    Maybe see the example at Visual Basic Code Example: Navigating Using Cursors for the bare bones if you have never worked with MSMQ.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2013
    Posts
    43

    Re: Oldest MSMQ message

    Thanks man. Thought so but your additions on the options to improve performance are most welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width