WCF单向回调计时?

时间:2011-04-13 17:08:29

标签: wcf wcf-callbacks

这怎么可能?我认为有一种方式是火,忘了。该方法标记为单向。回调并发模式设置为Multiple,回调类的UseSychronizationContext设置为false。发送的数据不超过1KB但每次同时发送大约30-40条小消息时,调用开始阻塞,最终一些超时。我已经以大约16000 /秒的速度对我的客户端 - >服务器调用进行了基准测试。当我尝试回电话给客户时,我只能每秒大约2次,这是在OneWay电话上的!

我对服务器的绑定配置如下所示:

<system.serviceModel>
<bindings>
  <netNamedPipeBinding>
    <binding name="netNamedPipeBinding1" receiveTimeout="23:00:00" maxReceivedMessageSize="1048576" maxBufferPoolSize="1048576" maxConnections="500">
      <readerQuotas maxStringContentLength="99999999" maxArrayLength="9999999" maxBytesPerRead="999999"/>
      <security mode="None"/>
    </binding>
  </netNamedPipeBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="highThroughPut">
      <serviceThrottling maxConcurrentCalls="3000" maxConcurrentInstances="3000" maxConcurrentSessions="3000"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="OLII.Apps.Services.Data.DataServices.DataService" behaviorConfiguration="highThroughPut">
    <endpoint bindingConfiguration="netNamedPipeBinding1" address="net.pipe://localhost/DataListener" binding="netNamedPipeBinding" contract="OLLI.Apps.Services.ProxyClients.DataServerProxyClient.IDataListenerService"/>
   </service>
</services>
</system.serviceModel>

我的回调合约如下:

   public interface IDataCallbackClient
    {
        [OperationContract(IsOneWay = true)]
        void GetData(string file, int id);
    }

我的客户端回调类如下所示:

   [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    public class DataCallback : IDataCallbackClient
    {
public void GetData(string file, int id)
{
//If I put Thread.Sleep(5000);  When the server calls this method, the first few go through, and subsequent calls block.  If I do a return statement here, all the calls go through really fast on the server side.
//Does some processing with file and id.  It then goes back to server with data.
}
}

1 个答案:

答案 0 :(得分:2)

我明白了。我调用了我的服务,在此过程中阻塞并使线程池匮乏。我也在我的wcf服务中调用线程池上的调用,这是一种不好的做法,因为这些方法是在线程池本身上调用的。看起来当你进行单向调用,并且线程池被饿了时,单向调用将超时,因为它没有要执行的线程。 感谢