2

I have a Web App and a service sitting on the same machine and communicating via message queues. The problem I'm experiencing is that about half of the time the messages I send from the service are not arriving to the reading code in the web app. Some of them will arrive and some will not. The messages are sent with at least 1 second delay between them.

To make things harder - I don't see ANY of my messages in the management console, even those that do arrive. I turned journaling on, but see no difference. I have full access to the queue.

I'm new to MSMQ and suppose it is something small I miss, but from reading online I could not figure it out.

The reading code looks like this:

public SomeMethod
{
 ...
    MessageQueue respQ = Utils.GetResponseQueue();
    respQ.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
    respQ.ReceiveCompleted += new ReceiveCompletedEventHandler(OnReceiveCompleted);
    respQ.BeginReceive();
}
public void OnReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult)
{
    MessageQueue replyQueue = (MessageQueue)source;
    Message replyMessage = replyQueue.EndReceive(asyncResult.AsyncResult);

    try
    {
          //process the message
          //...

    }
    catch (Exception)
    {
    }

    replyQueue.BeginReceive();
}

Would appreciate help on both missing messages and on messages not appearing in the management console

Moshe

2
  • Start by deleting that evil try/catch statement. Commented Oct 31, 2010 at 16:19
  • Well, I did - I switched to a periodic Receive on the queue. Now I'n not getting any messages. Commented Oct 31, 2010 at 18:00

1 Answer 1

2

Well, it seems I've resolved it.

  1. The issue with messages not seen in the management console seems really weird to me. I was creating the queue from my code if it did not existed (like in all samples out there). It turned out that if I set the queue label to something - I can see its messages in the management consoles. Otherwise - I can't. I did not look for the explanation, on the surface the things are not related in ay way and it seems like a bug to me.

  2. Missing messages - most proabably the problem was not in the queue, but in how I treated the read messages. I was retrieving them from a AJAX timer postback and adding to a session state variable. The problem I discovered was that this timer callback sometimes came in the original session, and sometimes - not. So I was not seeing some of my messages printed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.