Search code examples
c#msmq

No message in msmq


I writing a console app that add a message to local queue. But, no message is being inserted.

I created the queue as transactional and inserting like following:

      string path = @"FormatName:DIRECT=OS:computername\private$\myqueue";
        MessageQueue queue = new MessageQueue();
        queue.Path = path;            

        foreach (string msg in messages)
        {
            queue.Send("inputMessage", msg);

        }

Anything wrong with this?

Thanks.


Solution

  • Easy one, this. You are sending a non-transactional message to a transactional queue. MSMQ will discard the message.

    Use the "MessageQueue.Send(Object, MessageQueueTransaction)" Method

    If you enable Negative Source Journaling, you can look in the dead letter queue to see why messages gets discarded.

    Cheers
    John Breakwell