Search code examples
wcfservicebus

Service Bus Topics and Incoming Messages


I'm using NetMessagingBinding on a IIS hosted WCF service to consume messages published on a Windows Server Service Bus Topic.

From my understanding there is no limit on message size on Topics for Windows Server Service Bus, but nevertheless I'm getting an error deserializing a message from the subscription:

System.ServiceModel.Dispatcher.NetDispatcherFaultException: (...) 
The maximum string content length quota (8192) has been exceeded while reading XML data. 
This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'.  
Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type [Type]. 
The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. ---> System.Xml.XmlException: 
The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

The way i see it there is no configuration that i can change in WCF's web.config to change the maximum string content. The only property that could be related is MaxBufferPoolSize but it is not exposed through the web.config.

The binding configuration used is:

<bindings>
  <netMessagingBinding>
       <binding name="messagingBinding" 
                 closeTimeout="00:03:00" openTimeout="00:03:00"
                 receiveTimeout="00:03:00" sendTimeout="00:03:00"
                 prefetchCount="-1" sessionIdleTimeout="00:01:00">
       <transportSettings batchFlushInterval="00:00:01" />
     </binding>
   </netMessagingBinding>
</bindings>

Thanks in advance,

Joao Carlos de Sousa


Solution

  • This issue can also be solved by using a custom binding which uses the netMessagingTransport. This way the readerQuotas node can be use to define the reader quotas.

    <customBinding>
        <binding name="sbBindingConfiguration" sendTimeout="00:01:00" receiveTimeout="00:01:00" openTimeout="00:01:00">
          <binaryMessageEncoding>
                  <readerQuotas maxDepth="100000000" maxStringContentLength="100000000" 
                        maxArrayLength="100000000" maxBytesPerRead="100000000" maxNameTableCharCount="100000000"/>
         </binaryMessageEncoding>
          <netMessagingTransport  manualAddressing="false" maxBufferPoolSize="100000" maxReceivedMessageSize="100000000">
            <transportSettings batchFlushInterval="00:00:00"/>
          </netMessagingTransport>
        </binding>
      </customBinding> 
    

    Please refer to this post for more details on how to use the custom binding.