Search code examples
c#performancewcfmsmqmsmq-transaction

How do I make the MSMQ queues faster? Is there batch sending so at least it is not 1 by 1?


I have the following code, which is not that slow, and also not that fast. Is there anyway to improve this? I currently get 1000 messages in like 5 to 10 seconds, which isn't ideal yet in my opinion.

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

Processor not related answers please, I mean configuration-wise how to make it faster


Solution

  • With .net 4.5 you could use compression, but that would require completely rewriting you binding from the bottom up.

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