I have a WCF service which creates a number of files at a server location doing various calculation on seed file depending upon the params given. The problem is that, the when 2 or more clients try to do calculation on same seed file, it is returning error. The cause is simply due to read/write access by multiple users at a time. So I want to create a user request queue in WCF from where server does its calculation one at a time and returns calculated response to the user. The problem is I dont know how to do it.
I have not implemented any request queue technique in WCF before. Does anyone know how to implement this in WCF Sevcices. I cannot do threading as calculation depends upon the file I/O so handling one request at a time is only one solution at this time.
Any tutorial or video tutorial will be highly appreciated.
Finally I did it. Here I am posting my soluton for other users who may be new to the WCF request queuing. At first, we need to implement the throttling settings in WCF host file. Throttling can be done in two ways (Either way is OK):
Throttling settings in config file as follows:
Or throttling settings in code
With the above throttling settings a maximum of 3 concurrent calls are processed. In addition to maxConcurrentCalls property, maxConcurrentInstances and maxConcurrentSessions may also impact the number of calls processed concurrently.
Now after defining throttling behavior, we need to define concurrency mode in service contract as follows:
With these settings in placed, we can easily get the the request queuing in WCF service.