tags:

views:

61

answers:

2

I am working to speed up a large number of integration tests in our environment.

The problem I am facing right now is that during teardown between tests one WCF service using msmq binding takes about 1 minute to close down.

I the teardown process we loop over our servicehosts calling the Close() method with a very short timeout, overriding the closeTimeout value in the WCF configuration. This works well for net.tcp bindings but the one service that uses msmq still takes 1 minute to close down. The closeTimeout doesn't seem to have any effect.

The config look like this for the test service:

<netMsmqBinding>
    <binding name="NoMSMQSecurity" closeTimeout="00:00:01" timeToLive="00:00:05" 
             receiveErrorHandling="Drop" maxRetryCycles="2" retryCycleDelay="00:00:01" receiveRetryCount="2">
      <security mode="None" />
    </binding>
  </netMsmqBinding>

And the closing call I use is straight forward like this:

service.Close(new TimeSpan(0, 0, 0, 0, 10));

Is there another approach I can take to close down the servicehost faster?

As this is an automated test that at this point has succeded or failed I don't want to wait for any other unprocessed messages or similar.

Best regards,

Per Salmi

A: 

Could there be some transaction that is blocking the close.

Say for example there is an open transaction, if you close without commiting the transaction, then it will wait 1 min for the transaction to timeout before it can close.

Shiraz Bhaiji
You could be right, I'll have to check that when I get to the office in the morning... If I complete or abort the transaction before closing the service host maybe I could avoid the 1 minute timeout?
Per Salmi
There is an ambient transaction as the services are part of it but it should be committed by the time the test execution comes to the fixture teardown and tries to close the servicehosts. Any suggestions?
Per Salmi
Try the examples in this link http://msdn.microsoft.com/en-us/library/ms751493.aspx
Shiraz Bhaiji
A: 

I found the cause of the delayed closing down of the service host using Msmq.

The reason for the long close times seems to be that the service uses another net.tcp based service which has reliableSession activated and the servicehost. The reliableSession settings had an inactivity timeout set to 5 minutes which causes it to send keep-alive infrastructure messages, they should be sent every 2.5 minutes. This keep-alive messaging interval seems to cause the msmq based service to hang around for 1-2 minutes probably waiting for some of the keep-alive messages to arrive.

When I set the inactivityTimeout down to 5 seconds the shutdown of the msmq service completes in about 2.5 seconds. This makes the automatic integration tests pass a lot faster!

Per Salmi