简体   繁体   English

具有msmq绑定和closeTimeout的WCF服务?

[英]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. 我现在面临的问题是,在两次测试之间的拆除期间,使用msmq绑定的一个WCF服务需要大约1分钟才能关闭。

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. 在拆卸过程中,我们以非常短的超时循环遍历调用Close()方法的服务主机,从而覆盖WCF配置中的closeTimeout值。 This works well for net.tcp bindings but the one service that uses msmq still takes 1 minute to close down. 这对于net.tcp绑定效果很好,但是使用msmq的一项服务仍然需要1分钟才能关闭。 The closeTimeout doesn't seem to have any effect. closeTimeout似乎没有任何作用。

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. 我发现使用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. 关闭时间长的原因似乎是该服务使用了另一个基于net.tcp的服务,该服务已激活了可靠会话和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. 可靠会话设置的不活动超时设置为5分钟,这导致它发送保持活动的基础结构消息,应每2.5分钟发送一次。 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. 此保持活动消息传递间隔似乎导致基于msmq的服务挂起1-2分钟,可能等待一些保持活动消息到达。

When I set the inactivityTimeout down to 5 seconds the shutdown of the msmq service completes in about 2.5 seconds. 当我将inactivityTimeout设置为5秒时,关闭msmq服务的过程大约需要2.5秒。 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. 例如说有一个打开的事务,如果您关闭而不提交事务,那么它将等待1分钟使事务超时,然后才能关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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