none
Msmq Send() works, But not able to peek() or receive() from a remote server RRS feed

  • Question

  • I am able to send a message to a remote queue but I am not able to Peek() into the private queue or Receive messages from the private queue remotely

    When I debugged the Code, I found out that the value for canRead in the messageQueue object to be false

    Have enabled the inbound rules and outbound rules for the ports 135, 2103, 2105,1801, 3527

    private static string QueueName = "FormatName:Direct=TCP:Rdp public Ip Address\\private$\\taskQueue";

    public MsmQueue getMsmq()
            {
                MessageQueue msgQ = new MessageQueue(QueueName);
                MsmQueue msmq  = new MsmQueue();
    
                if (IsQueueEmpty())
                {
                    return msmq;
                }
    
                Object o = new Object();
                System.Type[] arrTypes = new System.Type[2];
                arrTypes[0] = msmq.GetType();
                arrTypes[1] = o.GetType();
                msgQ.Formatter = new XmlMessageFormatter(arrTypes);
                msmq = ((MsmQueue)msgQ.Receive().Body);
    
                return msmq;
            }

    private bool IsQueueEmpty()
            {
                bool isQueueEmpty = false;
    
    
                try
                {
                    MessageQueue msgQ = new MessageQueue(QueueName, QueueAccessMode.Peek);
                    Message message = msgQ.Peek();   // the code breaks at this point and throws the exception. 
                    isQueueEmpty = false;
                }
    
                catch (MessageQueueException e)
                {
                    if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
                    {
                        isQueueEmpty = true;
                    }
                }
                return isQueueEmpty;
            }



    Monday, June 24, 2019 10:38 AM