简体   繁体   English

发送MSMQ消息时如何解决名称转换失败

[英]How to resolve a name conversion failure when sending MSMQ messages

I've recently been following this article on how to set up a 3-party queueing system with MSMQ, wherein the publisher, queue server and subscriber are all on separate systems within an Active Directory domain. 我最近一直在下面这篇文章就如何建立一个三方排队系统,MSMQ,其中发布者,队列服务器和用户都在Active Directory域中的独立系统。 I've succeeded in completing Part 1 and the first half of Part 2. However, when I continue with the latter half of Part 2 and enable Transport security, I receive the following error: 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部分和第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. 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.

I've verified the following: 我已验证以下内容:

  1. Active Directory Integration for MSMQ is enabled on all the machines in the 3-party system, per this StackOverflow post . 根据此StackOverflow帖子 ,在三方系统中的所有计算机上都启用了MSMQ的Active Directory集成。
  2. The URL to the queue remains exactly the same as it was prior to enabling security, which worked just fine, no parsing errors whatsoever. 队列的URL与启用安全性之前的URL完全相同,该URL工作得很好,没有任何解析错误。
  3. I've following the instructions provided by Windows when installing MSMQ here . 在此处安装MSMQ时,我已按照Windows提供的说明进行操作。

The relevant parts of the stack trace I get are: 我得到的堆栈跟踪的相关部分是:

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)

Based on the content of the stack trace, it appears that the failure is coming from resolving the queue name within Active Directory. 根据堆栈跟踪的内容,似乎是由于解析Active Directory中的队列名称而导致失败。 I've tried the following to attempt to resolve such a failure: 我尝试了以下尝试来解决这种故障:

  1. Simplifying the name to contain no periods or slashes (didn't work) 将该名称简化为不包含句号或斜杠(无效)
  2. Using a public queue instead of a private queue, in the event that this step was omitted from the original tutorial on MSDN (it wasn't, didn't work) 如果在MSDN上的原始教程中省略了此步骤,则使用公共队列而不是私有队列(不是,是行不通的)

At this point, I'm out of ideas. 在这一点上,我没有主意。 Has anybody encountered this error when using WCF with net.msmq bindings before and solved their issue ? 以前有人将WCF与net.msmq绑定一起使用并解决了他们的问题吗?

EDIT: When running the following test code from the same machine and same user, I'm able to send a message to the queue perfectly fine: 编辑:从同一台计算机和同一用户运行以下测试代码时,我能够将消息发送到队列完全正常:

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)

By pure fluke, I stumbled across the solution, and I recorded it in my blog . 出于偶然,我偶然发现了该解决方案,并将其记录在我的博客中

The gist of the solution was that I had to add a DNS identity for my WCF endpoint binding in my client: 解决方案的要点是我必须为客户端中的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)

I apologize to the world for the Visual Basic code, it's a legacy application and wasn't my choice. 我为Visual Basic代码向世界表示歉意,这是一个遗留应用程序,不是我的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM