MSMQ active message

Berico
Berico used Ask the Experts™
on
I have written a windows service and process messages in a queue and sends and email per each message. I am also writing a windows application that monitors this queue and should determine which message is currently being send. Is there any way to look at a queue externally and determines which message is currently active. This is my winodws service peekcompeleted method:

 private void MyQueue_PeekCompleted(object sender, PeekCompletedEventArgs e)
        {
           
           
            try
            {
             
                incomingmessage = MyQueue.EndReceive(e.AsyncResult);
                incomingmessage.Formatter = new BinaryMessageFormatter();
                sendemail.sendqueuemail(incomingmessage);
                //During this stage when mail is being sent my external
               // application need to know the ID of the message
       
            }
            catch
            {
               

            }
            finally
            {
               // remove the message from the queue if its matches
                 EBTSQueue.Receive();
                 //refresh the Queue
                 EBTSQueue.Refresh();
                // start watching for another message
                EBTSQueue.BeginPeek();
            }
        }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
There is no event that you can use in external application to detect MSMQEvent.Received.

Perhaps, you can maintain status table in backend with timestamp or create text file for each message with comma separated values in a folder that is under watch by windows application. You can use FileSystemWatcher to watch a folder, as soon as windows application finishes you can delete that text file.

other pointers:
http://stackoverflow.com/questions/2760485/how-do-i-subscribe-to-a-msmq-queue-but-only-peek-the-message-in-net
Please tell me which approach you finally decided to go with.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial