Reading Messages from MSMQ

Posted on 2007-08-06
Last Modified: 2013-12-17

I am totally new to MSMQ. My requirement is something like this:
I know the path of message queue and i have to go through all the messages in that queue every 10 min....and check if there is any message which came in and is not proccessed and still is in queue for more than 10 min...then i have to perform certain functions or say display an alert message to user.

How do i read the message list and check the time it is being lying in the queue.

Some sample code would be great. My application is in C# ASP.NET 2.0

Question by:ziorrinfotech
    LVL 53

    Accepted Solution

    Code Snippet: Receiving a message in the .NET service:
    MessageQueue MyMessageQ;
    Message MyMessage;
    MyMessageQ = new MessageQueue(_QueuePath);
    MyMessage = MyMessageQ.Receive;      
    WriteStatus("Message Received!");
    WriteStatus("Processing Finished!");

    Source: Leveraging MSMQ in ASP.NET Applications

    How to do asynchronous programming using ASP.NET, MSMQ and Windows Service, for long running processes

    Author Comment

    when i unse sendtime property of message it give me exception and give this msg please use correct property filer in the reciveced mesage.
    so how i get the send time of the message

    Author Comment

    I got it..i also have to set MsgQ.MessageReadPropertyFilter.ArrivedTime = true;
    before reading it.
    LVL 2

    Expert Comment

    @ i also have to set MsgQ.MessageReadPropertyFilter.ArrivedTime = true;
    great efforts dude !

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now