首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF并发&多线程客户端

WCF并发&多线程客户端
EN

Stack Overflow用户
提问于 2017-06-19 12:19:40
回答 1查看 265关注 0票数 0

我有一个WCF,用于多线程客户端处理并行请求的数量。它以某种方式开始共享两个不同请求/线程的数据;我试图按以下方式更改InstanceContextModeConcurrencyMode

  • 默认InstanceContextMode = PerSession ConcurrencyMode = Single
  • InstanceContextMode = PerCall ConcurrencyMode =单项
  • InstanceContextMode = PerCall ConcurrencyMode = Multiple

但到目前为止还没有运气。没有可能导致此并发问题的共享变量和函数。根据MS文档,PerCall为每个调用创建实例,当实例拥有自己的私有内存堆栈时,如何在实例之间共享数据没有任何意义。

工作流: WCF有三个主要组件:.Net组装1和.Net组装2。WCF有一个名为"Process“的函数,它接受一个字符串参数,并根据通过WCF完成的处理返回结构化对象。WCF中没有实例变量;函数中的所有内容。该函数很少对字符串进行处理,并将其转换为结构化对象,然后将其传递给组装1的函数,进行一些处理,然后使用反射的调用方法将其传递给组装2的函数。这是整个过程,它以某种方式混合了两个不同并发调用的最终结果。

如果有人能帮助解决这个问题,我将非常感激。

EN

回答 1

Stack Overflow用户

发布于 2017-06-19 13:03:11

是否希望并行执行这些请求,但不希望按顺序执行这些请求?通过在配置文件中添加serviceThrottling,我对此没有问题。我的配置如下所示:

代码语言:javascript
复制
<system.serviceModel>
    <services>
      <service name="TeleEcgService.Service">
        <endpoint address="" binding="basicHttpBinding" contract="TeleEcgService.IService"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="1" maxConcurrentInstances="100"/>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="50000000">
          <!--
          <security mode="Transport">
          </security>
          -->
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

正如您所看到的,我可以有最多100个并行请求。我使用默认的InstanceContextModeConcurrencyMode

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44630416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档