none
Unable to create a message until restart RRS feed

  • Question

  • Hi there,

    I have W2012R2 with MSMQ.

    My MSMQ ends to the situations where I'm not anymore create a visible messages. Basically my code looks like:

    MessageQueue myQueue = new MessageQueue(".\\private$\\TheQueue");
    myQueue.Send("Private queue by path name.");

    Now and then the MSMQ ends to the state where I can run the code without any troubles. On the event log the MSMQ write:

    ----------

    Log Name:      Microsoft-Windows-MSMQ/End2End
    Source:        Microsoft-Windows-MSMQ
    Level:         Information
    Description:
    Message with ID {123482c7-30bb-47a3-85f6-dd5b45ec925f}\90115 was put into queue mqServer01\private$\TheQueue

    ----------

    But nothing appears to the queue. Now when I restart the MSMQ service, my code is working like human mind.

    Any idea from where to look this kind of issue?


    Petri

    Tuesday, May 7, 2019 3:57 PM

All replies

  • Hi,

    The new MSMQ created will not be immediately updated to the Private Message window until you reopen it. You could try the following sample to see if it works well.
    MSMQServer:
    using System;
    using System.Messaging;
    
    namespace MSMQServer
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (!MessageQueue.Exists(@".\Private$\TheQueue"))
                {
                    using (MessageQueue mq = MessageQueue.Create(@".\Private$\TheQueue"))
                    {
                        mq.Label = "LearningHardPrivateQueue";
                        Console.WriteLine("already create a Private MSMQ");
                        Console.WriteLine("Path:{0}", mq.Path);
                        Console.WriteLine("Private MSMQ Name:{0}", mq.QueueName);
                        mq.Send("MSMQ Private Message", MessageQueueTransactionType.Single); // send message
                    }
                }
                if (MessageQueue.Exists(@".\Private$\TheQueue"))
                {
                    // get Private MSMQ
                    MessageQueue mq = new MessageQueue(@".\Private$\TheQueue");
                    mq.Send("Sending MSMQ private message" + DateTime.Now.ToLongDateString(), "Leaning Hard");
                    Console.WriteLine("Private Message is sent to {0}", mq.Path);
                }
                Console.ReadKey();
            }
        }
    }

    MSMQClient:
    using System;
    using System.Messaging;
    
    namespace MSMQClient
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (MessageQueue.Exists(@".\Private$\TheQueue"))
                {
                    // create MSMQ
                    using (MessageQueue mq = new MessageQueue(@".\Private$\TheQueue"))
                    {
                        // set the Formatter of MSMQ
                        mq.Formatter = new XmlMessageFormatter(new string[] { "System.String" });
                        foreach (Message msg in mq.GetAllMessages())
                        {
                            Console.WriteLine("Received Private Message is: {0}", msg.Body);
                        }
    
                        Message firstmsg = mq.Receive(); // get the first message of MSMQ
                        Console.WriteLine("Received The first Private Message is: {0}", firstmsg.Body);
                    }
                }
                Console.ReadKey();
            }
        }
    }

    Best regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, May 8, 2019 10:07 AM
    Moderator
  • Big thanks Drake for this,

    I'll try your code when the next time I have the similar issue. But for your information, I do monitoring the MSMQ by the performance counter and there either I cannot see any evidences that new message has been arrived. I tried also F5 as refresh on the MMC, and no luck.

    But lets not give up ! :D


    Petri

    Monday, May 13, 2019 9:51 PM
  • Try to monitor the MSMQ in Computer Management(compmgmt.msc) > Services and Applications > Message Queuing > Private Queues. Once the message comes, reopen it to see if it is in it.

    Best regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 14, 2019 5:42 AM
    Moderator