【发布时间】:2015-01-20 15:45:26
【问题描述】:
我有用 C# 开发的 Windows 服务
我有带有 2 个私有队列的 Windows Server 2012:queueRequests 和 queueResponses。
我的队列不是事务性的。
我有使用凭据 MyDomain\UserDeploy 执行控制台应用程序的客户端。
服务器中的 Windows 服务使用凭据 MyDomain\UserAgent 执行。
MyDomain\UserAgent 和 MyDomain\UserDeploy 用户可以完全控制队列:queueRequests 和 queueResponses。
服务器和客户端在同一个 MyDomain 中。
控制台应用程序客户端向服务器中的私有队列发送消息和读取消息。
服务器中的 Windows 服务用于从/到私有队列发送消息和读取消息。
执行步骤:
控制台应用程序客户端将消息 A 发送到专用队列 服务器中的队列请求
Windows 服务从私有队列 queuerequests 中读取消息 A
Windows 服务 sendMessage B 到专用队列 queueresponses
控制台应用程序客户端从私有队列中读取消息 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 的更多信息。
我明白了
消息:null
MessageQueueErrorCode -2147023169
ErrorCode -2147467259
但未在 MessageQueueErrorCode 枚举中找到该代码。
-2147023169 值。十六进制:800706BF
-2147467259 值。十六进制:80004005
关于这些代码的信息不多。只有我得到:
0x80004005 -2147467259 E_Fail
0x800706BF -2147023169 PRC_S_Call_Failed_DNE
完整的跟踪异常:
消息:- MessageQueueErrorCode -2147023169 - ErrorCode-2147467259 堆栈跟踪:
在 System.Messaging.MessageQueue.MQCacheableInfo.get_ReadHandle()在 System.Messaging.MessageQueue.ReceiveBy(String id, TimeSpan timeout, 布尔删除、布尔 compareId、布尔 throwTimeout、 MessageQueueTransaction 事务,MessageQueueTransactionType 交易类型)
在 System.Messaging.MessageQueue.ReceiveByCorrelationId(String 相关 ID,TimeSpan 超时)
在 DeploymentAgent.Client.DeploymentInvoker.WaitForResponse()
【问题讨论】:
-
你在使用事务吗?你能在读/写部分添加几行代码吗?你有什么例外吗?
-
尝试捕获异常并检查MessageQueueErrorCode。您能否还显示您用于访问远程私有队列的路径?