2014-11-22 92 views
1

我的Windows服務開發C#客戶端無法讀取遠程MSMQ隊列,但可以發送到遠程隊列

我有Windows Server 2012中有2個私人隊列:queueRequests和queueResponses。

我的隊列是非交易

我有客戶端執行憑證MyDomain \ UserDeploy的控制檯應用程序。

服務器中的Windows服務使用憑據MyDomain \ UserAgent執行。

MyDomain \ UserAgent和MyDomain \ UserDeploy用戶對隊列queueRequests和queueResponses具有完全控制權。

服務器和客戶端位於同一個MyDomain中。

控制檯應用程序客戶端發送消息並從/向服務器中的專用隊列讀取消息。

服務器中的Windows服務發送消息並從/ toprivate隊列讀取消息。

的執行步驟:

  1. 控制檯應用程序客戶端發送消息到專用隊列 queuerequests在服務器

  2. Windows服務從專用隊列中讀取消息queuerequests

  3. Windows服務的sendMessage乙到私人隊列隊列響應

  4. 控制檯應用程序客戶端從專用隊列中讀取消息B 隊列響應。

這是工作的所有步驟。

現在,我不知道原因,第4步失敗。 客戶端不從遠程隊列讀取消息。

我不明白爲什麼:客戶端可以發送消息到隊列,但不能從隊列讀取。

我得到一個MessageQueueException但exception.Message是空的。

任何建議,以獲得良好的故障排除?

片段代碼:

const string ForSend = @"FormatName:DIRECT=OS:{0}\private$\DeploymentCommands"; 
    const string ForRead = @"FormatName:DIRECT=OS:{0}\private$\DeploymentResponses"; 

private DeploymentResponse WaitForResponse() 
     { 
      try 
      { 
       Message rsp = colaStatus.ReceiveByCorrelationId(correlationId, new TimeSpan(0, timeOut, 0)); 
       DeploymentResponse ret = rsp.Body as DeploymentResponse; 

       Console.WriteLine("Respuesta WaitForResponse:" + ret.DeploymentId + " - " + ret.Status); 
       Trace.WriteLine("Respuesta WaitForResponse:" + ret.DeploymentId + " - " + ret.Status); 
       return ret; 
      } 
      catch (MessageQueueException ex) 
      { 
       Console.WriteLine("Error WaitForResponse in remote server " + remoteServer + ". " + ex.Message); 
       Trace.WriteLine("Error WaitForResponse in remote server " + remoteServer + ". " + ex.Message); 
       return null; 
      } 
      catch (Exception) 
      { 
       throw; 
      } 
     } 

進一步瞭解MessageQueueException

我得到

消息:空
MessageQueueErrorCode -2147023169
錯誤代碼-2147467259

但不能發現的代碼MessageQueueErrorCode枚舉。

-2147023169值。在十六進制中:800706BF

-2147467259 value。在十六進制:

關於這些代碼沒有太多的信息。只有我得到:

0X80004005 -2147467259 E_FAIL
0x800706BF -2147023169 PRC_S_Call_Failed_DNE

Windows Update Codes

全面跟蹤異常:

消息: - MessageQueueErrorCode -2147023169 - ErrorCode- 2147467259 StackTrace:
在System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle()

在System.Messaging.MessageQueue.ReceiveBy(串ID,時間跨度超時, 布爾撈出,布爾compareId,布爾throwTimeout, MessageQueueTransaction交易,MessageQueueTransactionType TRANSACTIONTYPE )

在System.Messaging.MessageQueue.ReceiveByCorrelationId(字符串 的correlationID,時間跨度超時)

在DeploymentAgent.Client.DeploymentInvoker.WaitForResponse()

+0

使用你的交易?你可以在閱讀/寫作部分添加幾行代碼嗎?你有沒有例外? – b2zw2a 2014-11-22 17:46:45

+1

嘗試捕捉異常並檢查[MessageQueueErrorCode](http://msdn.microsoft.com/zh-cn/library/system.messaging.messagequeueerrorcode.aspx)。你還可以顯示你用來訪問遠程專用隊列的路徑嗎? – b2zw2a 2014-11-24 07:49:31

回答

0

事情你可以嘗試:

  1. 更改隊列的權限 - see here,嘗試設置權限爲 「所有人」(僅用於測試)。
  2. 嘗試在註冊表中設置AllowNonauthenticatedRPC - details here