开发者

MSMQ Messages not arriving

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 lo开发者_高级运维oks 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜