Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSMQ Async Bug?

Posted on 2004-07-31
7
Medium Priority
?
774 Views
Last Modified: 2012-06-21
I have an application that is using MSMQ.

I have written an event handler to handle async message receiving.

it looks something like this :

Private Sub handler(ByVal objt00 As Object, ByVal objt01 As ReceiveCompletedEventArgs)
...
...
' SHOULD BE TRUE IF THERE IS A MESSAGE, FALSE IF TIMEOUT EXPIRED
If objt01.AsyncResult.IsCompleted Then
 ' process message
Else
 ' look to see if shutdown waithandle has occured
 ' if not, resume listening with BeginReceive(TimeSpan)
End If
...
...
End Sub

I initially call BeginReceive(TimeSpan) in a different function

The problem I have is that even if the timeout expires the AsyncResult.IsCompleted flag is true - and there are no messages to process
Has anyone else had this problem or know what I'm doing wrong?

Thanks.
0
Comment
Question by:BJohnston
  • 3
  • 2
7 Comments
 

Author Comment

by:BJohnston
ID: 11685576
As an addendum to my previous post, this is the MSDN documentation from which I am drawing my conclusions as to how the event handler should function. . .

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessagingmessagequeueclassbeginreceivetopic2.asp


note especially the portion that reads...

This overload specifies a time-out. If the interval specified by the timeout parameter expires, this component raises the ReceiveCompleted event, but the IsCompleted property of the operation's associated IAsyncResult is false. Because no message exists, a subsequent call to EndReceive will throw an exception.



I have temporarily patched this by simply catching the exception generated by the errant call to EndReceive and started BeginReceive again. . . sigh
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11688722
intresting, the documentation agrees ... what if anything is the state of the result object at this point.
0
 

Author Comment

by:BJohnston
ID: 11711154
Having talked with a Microsoft technical representative i have been informed that there is a documentation error and that regardless of what triggers the callback (either a Message arrival or a timeout) the AsyncResult.IsCompleted flag will be true.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11711163
documentation error ... hmm ... sounds more like a functionality flaw to me :)
0
 

Author Comment

by:BJohnston
ID: 11913425
Please refund points as there was no answer to be had.  Thank you.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11946782
PAQed, with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

972 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