2013-06-28 33 views
0

我試圖使用WCF和NetMessagingBinding發佈消息到一個Windows服務服務總線主題和大郵件 - 至少603KB - 推操作拋出以下錯誤:WCF NetMessagingBinding和傳出配額

System.ServiceModel.QuotaExceededException: The maximum message size quota for outgoing messages (262144) has been exceeded. 

Server stack trace: 
    at System.Runtime.BufferedOutputStream.WriteCore(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Xml.XmlBinaryNodeWriter.FlushBuffer() 
    at System.Xml.XmlStreamNodeWriter.GetBuffer(Int32 count, Int32& offset) 
    at System.Xml.XmlStreamNodeWriter.UnsafeWriteUTF8Chars(Char* chars, Int32 charCount) 
    at System.Xml.XmlBinaryNodeWriter.UnsafeWriteText(Char* chars, Int32 charCount) 
    at System.Xml.XmlBinaryNodeWriter.WriteText(String value) 
    at System.Xml.XmlBaseWriter.WriteString(String value) 
    (...) 

從錯誤我發現問題不是序列化,因此我不能使用消息格式化程序。我還能用什麼來克服這種異常?有什麼想法嗎?

在此先感謝!

回答

1

此問題已通過將netMessagingBinding替換爲使用netMessagingTransport的customBinding來解決。

1-添加netMessagingTransport作爲綁定擴展:

<bindingElementExtensions> 
    <add name="netMessagingTransport" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    </bindingElementExtensions> 

2-添加自定義綁定:

<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> 

3-使用屬性maxReceivedMessageSize以限定適合的消息的大小的值即將交換

4-在端點中引用您的自定義綁定

<endpoint (...) binding="customBinding" bindingConfiguration="sbBindingConfiguration" />