matt_d_p
asked on
Timeout receiving asyncronous message using msmq
Hi
I'm trying to learn more about messaging and services using an example by Peter Bromberg from Egghead Cafe (http://www.eggheadcafe.com/articles/20041204.asp - code can be downloaded from http://www.eggheadcafe.com/articles/20041204.zip). The example runs on a single machine but I've been trying to get it to run with the client and server on seperate machines for about 3 days without luck. I added event log messages at different points and it seems to fall over at the async receive on the server (Invoker.cs in the MSMQInvokerService project):
try
{
//breaks at this point
Message msg=mq.EndReceive(ar);
//and goes to the catch
ICommand cReceived = (ICommand)msg.Body;
ServiceBroker.Logger.Write ToLog("ICo mmand Object Casted.",
System.Diagnostics.EventLo gEntryType .Informati on);
cReceived.Execute();
ServiceBroker.Logger.Write ToLog("Exe cuted Command at "+DateTime.Now.ToLongTimeS tring(),
System.Diagnostics.EventLo gEntryType .Informati on);
}
catch
{
ServiceBroker.Logger.Write ToLog("Tim eout!",
System.Diagnostics.EventLo gEntryType .Informati on);
}
If the service is invoked on the server this means that the message has gotten there, right? What am I doing wrong?
Matt
I'm trying to learn more about messaging and services using an example by Peter Bromberg from Egghead Cafe (http://www.eggheadcafe.com/articles/20041204.asp - code can be downloaded from http://www.eggheadcafe.com/articles/20041204.zip). The example runs on a single machine but I've been trying to get it to run with the client and server on seperate machines for about 3 days without luck. I added event log messages at different points and it seems to fall over at the async receive on the server (Invoker.cs in the MSMQInvokerService project):
try
{
//breaks at this point
Message msg=mq.EndReceive(ar);
//and goes to the catch
ICommand cReceived = (ICommand)msg.Body;
ServiceBroker.Logger.Write
System.Diagnostics.EventLo
cReceived.Execute();
ServiceBroker.Logger.Write
System.Diagnostics.EventLo
}
catch
{
ServiceBroker.Logger.Write
System.Diagnostics.EventLo
}
If the service is invoked on the server this means that the message has gotten there, right? What am I doing wrong?
Matt
ASKER
Thanks for the suggestion. Seems it is a timeout out but why? Why the difference between local and remotes? I'm on a home network with 2 pc's linked by a crossover cable. Shouldn't be any load at all.
This is the error in the remote log:
Event Type: Information
Event Source: ServiceBroker
Event Category: None
Event ID: 0
Date: 2006/06/07
Time: 09:45:44 PM
User: N/A
Computer: BIGBLACK
Description:
An Exception Occured:
System.Messaging.MessageQu eueExcepti on: Timeout for the requested operation has expired.
at System.Messaging.MessageQu eue.Asynch ronousRequ est.End()
at System.Messaging.MessageQu eue.EndAsy ncOperatio n(IAsyncRe sult asyncResult)
at System.Messaging.MessageQu eue.EndRec eive(IAsyn cResult asyncResult)
at MSMQInvokerService.Invoker .OnMessage Arrival(IA syncResult ar)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
While playing I've also introduced a bug in the client now:
FormatName:DIRECT=OS:bigbl ack\privat e$\command test //writeline of destinationQueue value
System.Messaging.MessageQu eueExcepti on: The specified format name does not suppo
rt the requested operation. For example, a direct queue format name cannot be de
leted.
at System.Messaging.MessageQu eue.SaveQu euePropert ies()
at System.Messaging.MessageQu eue.set_Us eJournalQu eue(Boolea n value)
at ClientSample.QueuedClient. QueueInvok erCommand( ICommand c, String destinati
onQueue) in C:\projects\PosMinder\Clie ntSample\Q ueuedClien t.cs:line 65
Could this contribute? It complains about the name format yet still seems to get to the server as I see the errors there. Very confusing?
This is the error in the remote log:
Event Type: Information
Event Source: ServiceBroker
Event Category: None
Event ID: 0
Date: 2006/06/07
Time: 09:45:44 PM
User: N/A
Computer: BIGBLACK
Description:
An Exception Occured:
System.Messaging.MessageQu
at System.Messaging.MessageQu
at System.Messaging.MessageQu
at System.Messaging.MessageQu
at MSMQInvokerService.Invoker
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
While playing I've also introduced a bug in the client now:
FormatName:DIRECT=OS:bigbl
System.Messaging.MessageQu
rt the requested operation. For example, a direct queue format name cannot be de
leted.
at System.Messaging.MessageQu
at System.Messaging.MessageQu
at ClientSample.QueuedClient.
onQueue) in C:\projects\PosMinder\Clie
Could this contribute? It complains about the name format yet still seems to get to the server as I see the errors there. Very confusing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I understand this correctly, there isn't a problem at the server, the server just writes this message each time it "times out" while checking for a message? That explains why I couldn't find anything wrong :). Let me go and find my real problem. Thanks for the help.
Yes, the ReceivedCompleted event will fire in the event of a timeout, but calling EndReceive if there is no message will cause the exception.
You can check the IsCompleted property of the AsyncResult object to see if a message was actually received.
You can check the IsCompleted property of the AsyncResult object to see if a message was actually received.
catch(Exception exception)
{
ServiceBroker.Logger.Write
System.Diagnostics.EventLo
}