Solved

Help understanding the following statement:   MSMQ_.PeekCompleted += new PeekCompletedEventHandler(MSMQ__PeekCompleted)

Posted on 2008-10-17
4
888 Views
Last Modified: 2013-11-15
Greetings:

I'm trying to debug some code that uses the class 'MessageQueue'

The program fails on this line:

MSMQ_.PeekCompleted += new PeekCompletedEventHandler(MSMQ__PeekCompleted);

...and the method looks like this:

protected void MSMQ__PeekCompleted(object sender, PeekCompletedEventArgs e)
        {
            ((MessageQueue)sender).EndPeek(e.AsyncResult);     // ********* LINE 114 ************
            Message m = ((MessageQueue)sender).Receive();
            this.Fire(m.Label, m.Body.ToString());
            MainLoop();
        }

Hoping to get help understanding what is being done so I can understand why the procedure times out.  The error message I get is:

System.Messaging.MessageQueueException was unhandled by user code
  Message="Timeout for the requested operation has expired."
  Source="System.Messaging"
  ErrorCode=-2147467259
  StackTrace:
       at System.Messaging.MessageQueue.AsynchronousRequest.End()
       at ProjectObjects.Module1.CCMSMQ.MSMQ__PeekCompleted(Object sender, PeekCompletedEventArgs e) in C:\Projects\ProjectObjects\Module1\CCMSMQ.cs:line 114
       at System.Messaging.MessageQueue.AsynchronousRequest.RaiseCompletionEvent(Int32 result, NativeOverlapped* overlappedPointer)


Thanks!
0
Comment
Question by:John500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
silemone earned 500 total points
ID: 22742502
as far as error:  it's tellin you that you need a try{}/catch (MessageQueueException ex) block around code...there you can stackTrace to get better error message that will be more geared to MessageQueue error


string errMessage = String.Empty;

protected void MSMQ__PeekCompleted(object sender, PeekCompletedEventArgs e)
{
          try
         {
            ((MessageQueue)sender).EndPeek(e.AsyncResult);     // ********* LINE 114 ************
            Message m = ((MessageQueue)sender).Receive();
            this.Fire(m.Label, m.Body.ToString());
            MainLoop();
         }
          catch (System.Messaging.MessageQueueException ex)
         {
                errMess += ex.StackTrace.ToString();
                return;
         }
}
0
 
LVL 21

Expert Comment

by:silemone
ID: 22742527
the reason for me placing errMessage is that when debugging, you can see value of exception there also...or you can print to a file called ErrorLog.Text that you can create ...i.e..


if (! errMess.Equals(String.Empty)
{
          //create or append to error file
}
0
 

Author Comment

by:John500
ID: 22744732
The message didn't change much but here is the additional info:

System.Messaging.Message End()
System.Collections.ListDictionaryInternal
Exception raised by MyDomain\John500 / from : SYSTEMXYZ / Version : 123

I used the existing notification routine which made it look like this:

 catch (System.Messaging.MessageQueueException exe)
            {
                NotifException.NotifExcep(exe, NotifyObjects.Notify, "MSMQ - Thread");
                return;
            }

NotifException.NotifExcep(......)
{
....
       MailMessage mail = new MailMessage();
        mail.To.Add("OrgNotification" + OrgEmail.InternalDomain);
        mail.From = new MailAddress("Account Organization<OrgUserAcc" + OrgEmail.InternalDomain + '>');
        mail.Subject = "[MSMQ Excep][" + System.Environment.MachineName + "][" + user + "]  - " + info;
              if (except != null)
                  {
                      mail.Body = except.Message + "\r\n\r\n";
                            mail.Body += except.Source + " -- " + except.GetType().AssemblyQualifiedName + "\r\n\r\n";
                      mail.Body += except.StackTrace + "\r\n\r\n";
                      mail.Body += except.TargetSite + "\r\n\r\n";
                      mail.Body += except.Data;
                  }
        mail.Body += "\r\n\r\nException raised by " + user + " / from : " + System.Environment.MachineName + " / Version : " + App.Version;
        mail.Body += "\r\n\r\nMore info: [" + info + "]";
        mail.IsBodyHtml = false;
        OrgEmail.SendMail(mail);

        if (EvtWindowsEvent)
              SaveExceptionInEvt(except, user, info);
...
}

Any thoughts now about why this routine is timing out?

Thanks
0
 

Author Comment

by:John500
ID: 22771866
I don't know what it was that corrected itself but I'm not getting this error any longer.

Thanks for input while it lasted.

If you get the chance please check out this question:

http://www.experts-exchange.com/Software/Message_Queue/Q_23835057.html
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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