【问题标题】:How to resolve a name conversion failure when sending MSMQ messages发送 MSMQ 消息时如何解决名称转换失败
【发布时间】:2016-08-29 23:48:04
【问题描述】:

我最近一直在关注this article,了解如何使用 MSMQ 设置 3 方队列系统,其中发布者、队列服务器和订阅者都位于 Active Directory 域中的不同系统上。我已成功完成第 1 部分和第 2 部分的前半部分。但是,当我继续第 2 部分的后半部分并启用传输安全时,我收到以下错误:An error occurred when converting the 'mymsmqservermachine.mydomain.network.ads\private$\Path/To/MyQueuedService.svc' queue path name to the format name: Unrecognized error -1072824300 (0xc00e0014). All operations on the queued channel failed. Ensure that the queue address is valid. MSMQ must be installed with Active Directory integration enabled and access to it is available.

我已验证以下内容:

  1. 根据this StackOverflow post,在 3 方系统中的所有计算机上都启用了 MSMQ 的 Active Directory 集成。
  2. 队列的 URL 与启用安全性之前完全相同,它工作得很好,没有任何解析错误。
  3. 在安装 MSMQ here 时,我已按照 Windows 提供的说明进行操作。

我得到的堆栈跟踪的相关部分是:

at System.ServiceModel.Channels.MsmqFormatName.FromQueuePath(String queuePath)
   at System.ServiceModel.Channels.MsmqUri.ActiveDirectory.UriToFormatName(Uri uri)
   at System.ServiceModel.Channels.MsmqOutputChannel.OpenQueue()
 --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Channels.MsmqOutputChannel.OpenQueue()
   at System.ServiceModel.Channels.MsmqOutputChannel.OnOpenCore(TimeSpan timeout)
   at System.ServiceModel.Channels.MsmqOutputChannel.OnBeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()
   at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject, TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.CommunicationObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.ServiceChannel.OnBeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()
   at System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject, TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.CommunicationObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.BeginCall(ServiceChannel channel, TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.BeginCallOnce(TimeSpan timeout, CallOnceManager cascade, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.ServiceChannel.BeginEnsureOpened(TimeSpan timeout, AsyncCallback callback, Object state)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureOpen(Boolean completedSynchronously)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureInteractiveInit(IAsyncResult result, Boolean completedSynchronously)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureInteractiveInit()
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin()
   at System.ServiceModel.Channels.ServiceChannel.BeginCall(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, TimeSpan timeout, AsyncCallback callback, Object asyncState)
   at System.ServiceModel.Channels.ServiceChannel.BeginCall(ServiceChannel channel, ProxyOperationRuntime operation, Object[] ins, AsyncCallback callback, Object asyncState)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2,TArg3](Func`6 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, TArg3 arg3, Object state, TaskCreationOptions creationOptions)
   at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateTask(ServiceChannel channel, ProxyOperationRuntime operation, Object[] inputParameters)
   at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateTask(ServiceChannel channel, IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

根据堆栈跟踪的内容,故障似乎来自解析 Active Directory 中的队列名称。我尝试了以下方法来尝试解决此类故障:

  1. 将名称简化为不包含句点或斜杠(无效)
  2. 使用公共队列而不是私有队列,以防 MSDN 上的原始教程中省略了此步骤(没有,没有用)

在这一点上,我没有想法。有没有人在使用 WCF 和 net.msmq 绑定时遇到过这个错误并解决了他们的问题?

编辑:当从同一台机器和同一用户运行以下测试代码时,我可以完美地向队列发送消息:

Me.TestContext.WriteLine("Executing under user '{0}'", WindowsIdentity.GetCurrent().Name)

Dim msg = New System.Messaging.Message()

msg.Body = "This is a test message"
msg.Label = "Test Message"
msg.Formatter = new ActiveXMessageFormatter()

Dim queue = new MessageQueue("FormatName:DIRECT=OS:mymsmqservermachine.mydomain.network.ads\private$\Path/To/MyQueuedService.svc")

queue.Send(msg)

【问题讨论】:

  • 您说问题仅在您启用传输安全性时出现,因此这应该是身份验证/认证问题,而不是与您如何命名队列有关。我意识到 0xc00e0014 意味着 MQ_ERROR_ILLEGAL_QUEUE_PATHNAME 但这可能是一个红鲱鱼。
  • @JohnBreakwell 好主意,我没有考虑过。我刚刚调查,我的机器在域控制器的 1 秒内,它们都是网络同步的。
  • 如果您在队列属性中启用“已验证”选项,您的测试代码是否有效?如果你得到 0xC00E002F - MQ_ERROR_NO_INTERNAL_USER_CERT - 结果会感兴趣。
  • @JohnBreakwell 当我启用“Authenticated”时,什么都没有发生:“Send”方法没有抛出异常,也没有任何东西进入队列。队列中没有消息,没有消息被记录,系统“死信消息”队列中没有任何内容

标签: wcf msmq wcf-binding netmsmqbinding


【解决方案1】:

纯属侥幸,我偶然发现了这个解决方案,我recorded it in my blog

解决方案的要点是我必须在我的客户端中为我的 WCF 端点绑定添加一个 DNS 身份:

Dim endpointAddress = New EndpointAddress(queueUri, EndpointIdentity.CreateDnsIdentity(queueUri.Host))

Dim netMsmqBinding = New NetMsmqBinding With
{
    .Durable = true,
    .ExactlyOnce = false,
    .UseActiveDirectory = false,
    .Security = New NetMsmqSecurity With
    {
        .Mode = NetMsmqSecurityMode.Transport
    }
}

Return New ChannelFactory(Of ICwteCentralPublishingServiceChannel)(netMsmqBinding, endpointAddress)

我为 Visual Basic 代码向全世界道歉,它是一个遗留应用程序,不是我的选择。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-07
    • 2019-05-02
    • 1970-01-01
    • 2010-10-16
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多