Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Wcf并行和异步调用?_C#_Wcf_Asynchronous_Call_Parallel Processing - Fatal编程技术网

C# Wcf并行和异步调用?

C# Wcf并行和异步调用?,c#,wcf,asynchronous,call,parallel-processing,C#,Wcf,Asynchronous,Call,Parallel Processing,我有一个wcf服务(解析器服务,字节[]=>string) 托管在iis上(nettcpbinding) 在我的客户端,我有一百万字节以上的[],类似于这个列表(1000000),我应该调用wcf服务的方法来并行解析这个列表 我是这样使用的,但是在500000-700000消息解析之后,我遇到了一个瓶颈(wcf服务没有响应我)。我在哪里犯了错误?如果我实现这个方法,它能解决我的问题吗 我的wcf主机配置: <system.serviceModel> <diagnosti

我有一个wcf服务(解析器服务,字节[]=>string)

托管在iis上(nettcpbinding) 在我的客户端,我有一百万字节以上的[],类似于这个列表(1000000),我应该调用wcf服务的方法来并行解析这个列表

我是这样使用的,但是在500000-700000消息解析之后,我遇到了一个瓶颈(wcf服务没有响应我)。我在哪里犯了错误?如果我实现这个方法,它能解决我的问题吗

我的wcf主机配置:

<system.serviceModel>
    <diagnostics etwProviderId="9a712944-02ea-425a-bbd3-567a943b85df">
      <endToEndTracing propagateActivity="false" messageFlowTracing="false" />
    </diagnostics>
    <services>
      <service name="Pln3G.Services.EventParserService" behaviorConfiguration="Pln3G.WebServices.EventParserServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8001/pln3g/EventParserService/" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcp_Unsecured" contract="Pln3G.Domain.Contracts.Service.IEventParserService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="tcp_Unsecured" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:10:00">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="Pln3G.WebServices.EventParserServiceBehavior">
          <etwTracking profileName="ErrorsOnly Tracking Profile" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!--1. MaxConcurrentSessions: default is 100 * ProcessorCount
                2. MaxConcurrentCalls: default is 16 * ProcessorCount
                3. MaxConcurrentInstances: default is the total of MaxConcurrentSessions and MaxConcurrentCalls -->
          <serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="200" maxConcurrentInstances="232" />
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
        <behavior name="">
          <etwTracking profileName="HealthMonitoring Tracking Profile" />
          <serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="200" maxConcurrentInstances="232" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IEventParserService" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <!--<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />-->
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://192.168.1.66:8001/pln3g/EventParserService.svc" behaviorConfiguration="ServiceViewEventBehavior"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventParserService"
          contract="EventParserServiceReference.IEventParserService" name="NetTcpBinding_IEventParserService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceViewEventBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

我的wcf客户端配置:

<system.serviceModel>
    <diagnostics etwProviderId="9a712944-02ea-425a-bbd3-567a943b85df">
      <endToEndTracing propagateActivity="false" messageFlowTracing="false" />
    </diagnostics>
    <services>
      <service name="Pln3G.Services.EventParserService" behaviorConfiguration="Pln3G.WebServices.EventParserServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8001/pln3g/EventParserService/" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcp_Unsecured" contract="Pln3G.Domain.Contracts.Service.IEventParserService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="tcp_Unsecured" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="false" transactionFlow="false" listenBacklog="2147483647" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:10:00">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="Pln3G.WebServices.EventParserServiceBehavior">
          <etwTracking profileName="ErrorsOnly Tracking Profile" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!--1. MaxConcurrentSessions: default is 100 * ProcessorCount
                2. MaxConcurrentCalls: default is 16 * ProcessorCount
                3. MaxConcurrentInstances: default is the total of MaxConcurrentSessions and MaxConcurrentCalls -->
          <serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="200" maxConcurrentInstances="232" />
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
        <behavior name="">
          <etwTracking profileName="HealthMonitoring Tracking Profile" />
          <serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="200" maxConcurrentInstances="232" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IEventParserService" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <!--<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />-->
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://192.168.1.66:8001/pln3g/EventParserService.svc" behaviorConfiguration="ServiceViewEventBehavior"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventParserService"
          contract="EventParserServiceReference.IEventParserService" name="NetTcpBinding_IEventParserService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceViewEventBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>


我建议您使用PerCall InstanceContextMode,在这种模式下,它为不同的调用创建不同的实例,并在不同的线程中调用它们;如果您使用PerSession,它只为您的会话创建一个实例,根据您的客户端代码,它只创建实例并为您的请求提供服务。

在PerCall情况下;我是否需要从Service1客户端并行创建新实例。Foreach循环?挂起服务需要多少时间(大约)?它会在5分钟以上睡眠,同时不响应数据检查,并查看是否给您提供线索