WCF service accepting concurrent requests

131 views Asked by At

I am new to WCF web services. My requirement is to create a WCF service which is a wrapper for third-party COM dll object.

Let's assume that the dll takes 5 sec to calculate one particular input.

When I created the service and tested it (using the WCF test client) the scenario I see that I am not able to send 2nd request until first request is completed.

So I was thinking to start a new thread for consuming the com functionality and call a callback function once done. I want to send the response and end request in this callback function. This is for every request that hits the WCF service.

I have tested this, but problem is I am getting the response without completing the request.

I want current thread to wait until the calculations are done and also accept other requests in parallel

Can you please let me know how I can fix this considering the performance?

My service will be consumed by multiple SAP Portals clients via SAP PI

1

There are 1 answers

0
amit On

The concurrencymode for service can be set applying [ServiceBehavior] attribute on Service Class implementing ServiceContract. http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode(v=vs.110).aspx

However, in your situation where you access a COM component in service operation, I'd first check the Threading model for COM component i.e. does it implement Apartment (STA) or MTA. If COM component implements Apartment threading model, COM call invocation will be serialized. Thus, changing WCF ConcurrencyMode will not have any impact.

HTH, Amit Bhatia