0

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

MilkTea027
  • 301
  • 1
  • 5
  • 24
  • that's not code: it's configuration.... – Mitch Wheat Feb 20 '13 at 01:48
  • Right, fixed that then, so you have a solution for me? – MilkTea027 Feb 20 '13 at 02:26
  • To be honest, the speed at which messages are sent to an MSMQ service should not be important (unless the service is being starved of messages). MSMQ binding is about writing asynchronous services. If the send operation is blocking the client, the solution is possibly to BackgroundWorker the send operation. – Aron Feb 20 '13 at 02:27
  • A send call will just ask the queue manager to put messages into the outgoing queue before handing back control to the application. In this case the QM will put the messages straight into the local private Products queue as an outgoing queue is not required. That part should be very quick indeed. – John Breakwell Feb 20 '13 at 12:40

2 Answers2

0

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>
Aron
  • 15,464
  • 3
  • 31
  • 64
0

If performance is the only thing that you are looking for and are willing to sacrifice persistence then I would advise that you investigate non-transactional memory queues. They have no transaction overhead, and since they are not serialized to disk they are quite fast. You will still have to deal with network latency however if you are in a distributed environment.

Hope this helps,

Karell Ste-Marie
  • 1,022
  • 1
  • 10
  • 22