0

我有以下代码,不是那么慢,也不是那么快。有没有办法改善这一点?我目前在 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>

请与处理器无关的答案,我的意思是配置方面如何使其更快

4

2 回答 2

0

使用 .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>
于 2013-02-20T02:34:31.317 回答
0

如果性能是您唯一需要并愿意牺牲持久性的东西,那么我建议您调查非事务性内存队列。它们没有事务开销,并且由于它们没有序列化到磁盘,它们非常快。但是,如果您处于分布式环境中,您仍然必须处理网络延迟。

希望这可以帮助,

于 2013-02-22T16:01:38.050 回答