Skip to content

Conversation

@andreasohlund
Copy link
Member

@andreasohlund andreasohlund commented May 27, 2024

Version 3.0.0 of the MSMQ source package emits a BOM into the message headers, this causes older versions of transports not expecting a BOM to throw when attempting to deserializer message headers:

2024-05-24 09:50:35.097 WARN  Message '7e47b130-25e6-4b43-baf0-2339b773687a\105607' has corrupted headers
System.InvalidOperationException: There is an error in XML document (1, 1). ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlReader.MoveToContent()
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderList1.Read3_ArrayOfHeaderInfo()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at NServiceBus.Transport.Msmq.MsmqUtilities.DeserializeMessageHeaders(Message m)
   at NServiceBus.Transport.Msmq.MsmqUtilities.ExtractHeaders(Message msmqMessage)
   at NServiceBus.Transport.Msmq.ReceiveStrategy.TryExtractHeaders(Message message, Dictionary`2& headers)

Root cause

These versions were using Encoding.UTF8.GetString to get the data to deserialize via XmlReader which can't handle a BOM.

ServiceControl versions affected

This issue was introduced in https://github.com/Particular/ServiceControl/releases/tag/5.2.0 since that is the first version that uses the source package for MSMQ.

NServiceBus versions affected

  • NServiceBus v7.X when NServiceBus.Transport.Msmq v1.0.X is used (later versions does not have the issue)
  • NServiceBus v6.X (msmq bundled in core)
  • NServiceBus v5.X (msmq bundled in core)

See Particular/NServiceBus.Transport.Msmq#711 for more details

@andreasohlund andreasohlund self-assigned this May 27, 2024
@andreasohlund andreasohlund requested a review from bording May 27, 2024 11:12
@andreasohlund andreasohlund changed the title Retries and integration message fails to deserialize on older MSMQ endpoints Retries and integration messages fails to deserialize on older MSMQ endpoints May 27, 2024
@andreasohlund andreasohlund merged commit c0c0002 into master May 28, 2024
@andreasohlund andreasohlund deleted the msmq-patch branch May 28, 2024 15:10
@andreasohlund andreasohlund changed the title Retries and integration messages fails to deserialize on older MSMQ endpoints Retried messages and ServiceControl integration messages cannot be handled by older MSMQ endpoints May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants