I need some help on consuming windows service from a WCF service using multi-threading.
We have to implement a windows service in a secured corporate network which should pick requests synchronously from a WCF service hosted in internet. The windows service will process the request and send back a file to the WCF service.
Normally the windows service will process each request 1-2 mins approx and there can be multiple requests generated by the WCF service at same time.
I would like to know the best approach to implement this scenario or is there an already existing/proven solution which gives the best performance.
Would appreciate your valuable suggestions.
We use Visual studio 2010 and c# for development.
I am not sure how your WCF service is going to communicate with Windows Service? Do you mean your window service is hosting another WCF service which receive request from your internet WCF service?
If it is true,
WCF itself do concurrent request processing by setting ConcurrencyMode<//span>=Multiple and throttling behavior to manage server load and resource consumption (with the following properties):
- MaxConcurrentCalls. Limits the number of concurrent requests that can be processed by all service instances. The default value is 16.
- MaxConcurrentInstances. Limits the number of service instances that can be allocated at a given time. For PerCall services, this setting matches the number of concurrent calls. For PerSession services, this setting matches the number of active session instances. This setting doesn t matter for Single instancing mode, because only one instance is ever created. The default value for this setting is 2,147,483,647.
- MaxConcurrentSessions. Limits the number of active sessions allowed for the service. This includes application sessions, transport sessions (for TCP and named pipes, for example), reliable sessions, and secure sessions. The default value is 10.
So if you set MaxConcurrentCalls=10 than 10 threads would process10 request (10 files) in parallel by abstracting all multi-threading code.
Of course there are many other many options like MQ , Async you can think of.
- Изменено Lingaraj Mishra 10 марта 2012 г. 5:27
Thanks for the quick response Rupex & Lingaraj
We already use asynchronous method with MSMQ in other application. But this one we would like to do it in synchronous way.
Probably the Windows service is not going to to take 1-2 mins as i said earlier. Normally it take few seconds only max of 5 sec which we think may not have serious lock issues.
There is only one WCF from internet which needs to have two way communication with Windows service in Secured Network.
I am also working on to establish inter process communication between win Service (server) and WCF (client) mostly with Named Pipe as it supports multi threading.
Would appreciate if anyone can suggest any synchronous method of communication.