订阅NServiceBus 2.5端点从NServiceBus 2.5端点发布的消息

时间:2015-02-12 17:21:02

标签: nservicebus

我有两个端点,一个是NSB 2.5并发布消息,一个是NSB 4.7.5。我想订阅NSB2在我的NSB4端点中发布的事件,但是当我将订阅添加到NSB4端点时,我在NSB2端点中收到以下错误:

System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at NServiceBus.Serializers.XML.MessageSerializer.Deserialize(Stream stream) in c:\dev\v3\NServiceBus\src\impl\Seri
   at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.Extract(Message message) in c:\dev\v3\NServiceBus\src\impl\uni
   at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.ReceiveFromQueue() in c:\dev\v3\NServiceBus\src\impl\unicast\N

以下是我的NSB2错误队列:

<?xml version="1.0"?>
<ArrayOfHeaderInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <HeaderInfo>
    <Key>NServiceBus.MessageId</Key>
    <Value>7ffbe1e3-9b2c-456c-bcb7-a43d011a2389</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.CorrelationId</Key>
    <Value>7ffbe1e3-9b2c-456c-bcb7-a43d011a2389</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.OriginatingEndpoint</Key>
    <Value>NSB4Client</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>$.diagnostics.originating.hostid</Key>
    <Value>75e8656bb268f44ded5f2a82b8798e6a</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.MessageIntent</Key>
    <Value>Subscribe</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.Version</Key>
    <Value>4.7.5</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.TimeSent</Key>
    <Value>2015-02-12 17:07:14:158882 Z</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.OriginatingMachine</Key>
    <Value>xxx</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>NServiceBus.ControlMessage</Key>
    <Value>True</Value>
  </HeaderInfo>
  <HeaderInfo>
    <Key>SubscriptionMessageType</Key>
    <Value>MyMessages.EventMessage, MyMessages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Value>
  </HeaderInfo>
</ArrayOfHeaderInfo>

我假设这是因为标头在4和2之间不兼容,在这种情况下我应该能够使用mutator转换为兼容格式,但是我尝试使用mutator拦截NSB4端点上的传出消息但它似乎没有拦截消息(使用IMutateTransportMessages和IMutateMessages)

更新2015-02-16 似乎根据https://groups.google.com/forum/#!topic/particularsoftware/XVLQkCouKCk在4.3中禁用了订阅的传出mutator。这可以解释为什么我的传出mutator解决方案不起作用

1 个答案:

答案 0 :(得分:1)

V2.5期望消息被包装在根节点中,即使只发送了一条消息。默认情况下,该设置在v4中处于关闭状态。

通过致电:

打开它

https://github.com/Particular/NServiceBus/blob/4.7.5/src/NServiceBus.Core/Settings/SerializationSettings.cs#L11