Can I call multiple operation contracts when ConcurrencyMode is Single
I have a WCF service with 3 operation contracts. I set [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single)]
for this service. My ba开发者_JAVA技巧sic doubt is can I able to call all the 3 service at a time or only one contracts can be called at once. Please can any one give a solution.
Concurrency mode has scope for instance context mode. If you set ConcurrencyMode
to Single
you just tell WCF that each service instance can handle only one concurrent request - Single
is also default value for ConcurrencyMode
.
Unless you configure InstanceContextMode
to Single
as well (= you will make your service singleton) your service host will spawn new service instance either for each request (stateless bindings like BasicHttpBinding
or WebHttpBinding
) or for each connected proxy (statefull bindings like NetTcpBinding
, NamedPipeBinding
and some configurations of WsHttpBinding
). In the former case ConcurrencyMode
doesn't have any effect because each service instance is used only to handle single request = requests from any number of clients can be handled concurrently. In later case ConcurrencyMode.Single
tells that requests from single client proxy are handled in sequential order but requests from multiple client proxies can be handled concurrently. Each exposed contract requires separate endpoint and each consumed endpoint on a client requires separate proxy instance so proxy for each contract will have separate service instance in this case.
With your current configuration only service throttling controls how many concurrent clients can consume your service.
Once you set InstanceContextMode
to Single
as well you will indeed have the service which will be able to handle only single request at one time. The number of implemented contracts doesn't matter because all contracts exposed in endpoints on single service are in this case handled by single service instance which accepts only one concurrent request.
精彩评论