locked
MSMQ bug...?

    Question

  • I have two applications that uses MSMQ for duplex communication, host and client.
    The host has an in-queue (Q1) where the client sends messages to the host. When a client sends a "register"-message, a new queue (Q2) is created by the host, where the client can receive answers from the host.
    The procedure in the client is like this:
    1. Client connects to the hosts queue, Q1.
    2. Client send a register message to Q1.
    3. Client waits until Q2 is created with: MessageQueue.Exists(path of Q2)
    4. MessageQueue.Exists(path of Q2) returns true.
    5. Client creates a MessageQueue object (MessageQueue q1 = new MessageQueue(path of Q2))
    6. Client registers formatter, eventhandler for ReceiveCompletedEvent.
    7. Client invokes q1.BeginReceive().

    The host procedure is like follows:
    1. Host listens for incoming registrations in Q1.
    2. When registration is received, host creates a new queue (Q2) for that client with MessageQueue.Create(path of Q2).

    The problem is that MessageQueue.Exists returns true after a while, but when Beginreceive is invoked in the client i get the following exception:

    System.Messaging.MessageQueueException was unhandled
      Message="The queue does not exist or you do not have sufficient permissions to perform the operation."
      Source="System.Messaging"
      ErrorCode=-2147467259
      StackTrace:
           at System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle()
           at System.Messaging.MessageQueue.ReceiveAsync(TimeSpan timeout, CursorHandle cursorHandle, Int32 action, AsyncCallback callback, Object stateObject)
           at System.Messaging.MessageQueue.BeginReceive()
           at ApplicationServer.ApplicationServerMSMQ..ctor() in D:\WIP\src\WIP_API\AS_MSMQ\ApplicationServerMSMQ.cs:line 90
           at ApplicationServer.ApplicationServerMSMQ.Main(String[] args) in D:\WIP\src\WIP_API\AS_MSMQ\ApplicationServerMSMQ.cs:line 121
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    What is wrong and what could be done to avoid it?

    Tuesday, January 09, 2007 2:31 PM

Answers

  • Your exception seems to indicate that the client does not have receive permissions set on the queue.  Does your host application grant permissions to the remote client?  If the host and client apps run under different user accounts, you need to ensure that receive permissions are granted to the client.  Have a look at the SetPermissions method for some examples on how to do this.
    Tuesday, March 20, 2007 8:36 PM

All replies

  • I have the same problem.
    MessageQueue.Exists always return true for every queue name like:
    ".\private$\abc"
    ".\private$\test123"
    ".\private$\xyz"
    ".\private$\pippo"
    Wednesday, March 14, 2007 4:29 PM
  • Your exception seems to indicate that the client does not have receive permissions set on the queue.  Does your host application grant permissions to the remote client?  If the host and client apps run under different user accounts, you need to ensure that receive permissions are granted to the client.  Have a look at the SetPermissions method for some examples on how to do this.
    Tuesday, March 20, 2007 8:36 PM