简体   繁体   中英

WCF service with msmq binding and closeTimeout?

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM