我有下面的代码,它没有那么慢,也没有那么快。有什么可以改进的吗?我目前在5到10秒内收到1000条信息,在我看来这还不理想。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netMsmqBinding>
<binding name="NetMsmqBinding_IProductService"
deadLetterQueue="System"
maxReceivedMessageSize="524288">
<readerQuotas maxDepth="32"
maxStringContentLength="524288"
maxBytesPerRead="524288"/>
<security mode="None"/>
</binding>
</netMsmqBinding>
</bindings>
<client>
<endpoint address="net.msmq://localhost/private/Products" binding="netMsmqBinding"
bindingConfiguration="NetMsmqBinding_IProductService" contract="Products.IProductService"
name="NetMsmqBinding_IProductService" />
</client>
</system.serviceModel>
</configuration>
处理器不相关的答案请,我的意思是配置方面如何使其更快
使用.net 4.5可以使用压缩,但这需要从下到上完全重写绑定。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CompressedNetMsmqBinding_IProductService"
>
<binaryMessageEncoding compressionFormat="GZip" >
<readerQuotas maxDepth="32"
maxStringContentLength="524288"
maxBytesPerRead="524288"/>
</binaryMessageEncoding>
<msmqTransport
deadLetterQueue="System"
maxReceivedMessageSize="524288"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.msmq://localhost/private/Products" binding="netMsmqBinding"
bindingConfiguration="NetMsmqBinding_IProductService" contract="Products.IProductService"
name="CompressedNetMsmqBinding_IProductService" />
</client>
</system.serviceModel>
</configuration>
如果性能是您唯一想要的,并且愿意牺牲持久性,那么我建议您调查非事务性内存队列。它们没有事务开销,而且由于它们没有序列化到磁盘,所以速度相当快。但是,如果您在分布式环境中,您仍然需要处理网络延迟问题。
希望这有帮助,