我有一个WCF,用于多线程客户端处理并行请求的数量。它以某种方式开始共享两个不同请求/线程的数据;我试图按以下方式更改InstanceContextMode和ConcurrencyMode:
但到目前为止还没有运气。没有可能导致此并发问题的共享变量和函数。根据MS文档,PerCall为每个调用创建实例,当实例拥有自己的私有内存堆栈时,如何在实例之间共享数据没有任何意义。
工作流: WCF有三个主要组件:.Net组装1和.Net组装2。WCF有一个名为"Process“的函数,它接受一个字符串参数,并根据通过WCF完成的处理返回结构化对象。WCF中没有实例变量;函数中的所有内容。该函数很少对字符串进行处理,并将其转换为结构化对象,然后将其传递给组装1的函数,进行一些处理,然后使用反射的调用方法将其传递给组装2的函数。这是整个过程,它以某种方式混合了两个不同并发调用的最终结果。
如果有人能帮助解决这个问题,我将非常感激。
发布于 2017-06-19 13:03:11
是否希望并行执行这些请求,但不希望按顺序执行这些请求?通过在配置文件中添加serviceThrottling,我对此没有问题。我的配置如下所示:
<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个并行请求。我使用默认的InstanceContextMode和ConcurrencyMode
https://stackoverflow.com/questions/44630416
复制相似问题