Reputation: 1287
We have a WCF service like
Public Class MyService
{
[OperationContract]
Public void OpperationA()
{
}
[OperationContract]
Public void OpperationB()
{
}
[OperationContract]
Public void OpperationC()
{
}
[OperationContract]
Public void OpperationD()
{
}
}
We have a client for this WCF service which is a windows service which invokes all the operations above OperationA/B/C/D with new proxies.
With the current implementation we have there are issues with Client Invoking all operations at the same time.
InstanceContextMode = PerCall and ConcurrencyMode = Single
Is there any combination of InstanceContextMode and COncurrency which Can change my service to take only one request at a time, I mean if client proxy A has called OPerationA and the service is processing the request and if the Client proxy B tries to call OperationB (or any other operation), it should be blocked until the first request is finished.
Thanks
Upvotes: 2
Views: 1878
Reputation: 2233
It should be sufficient to change the InstanceContextMode to Single. From the MSDN documentation here:
ConcurrencyMode=Single : The service instance is single-threaded and does not accept reentrant calls. If the InstanceContextMode property is Single, and additional messages arrive while the instance services a call, these messages must wait until the service is available or until the messages time out.
Upvotes: 3
Reputation: 307
From http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode%28v=vs.110%29.aspx
If the InstanceContextMode value is set to Single the result is that your service can only process one message at a time unless you also set the ConcurrencyMode value to Multiple.
Obviously that won't work if you have multiple service hosts.
Upvotes: 0