So the question is does WCF4 invokes client connection pooling to WCF-service? For instance, we have ASP .NET application as client and service (on separate machines). Then somewhere in code we have something like that:
ServiceClient client = new ServiceClient();
// Here some work with service goes...
Lets say we have another service invoke in anither piece of code:
ServceClient client2 = new ServiceClient();
// Another one processing...
So will client2 connection taken from connection pool?
The "pooling" is dependent on used transport protocol. For HTTP the WCF by default uses HTTP persistent connections which live for short period of time (they are closed after 100s of inactivity) and can be reused by subsequent requests (even from different proxy instance). For TCP and Named pipes WCF provides built-in pooling.
Why would you do that? WCF can accept multiple Requests over one Client with ConcurrencyMode.Multiple
. So it wouldn't make much sense to initialize two Clients..
WCF ServiceContract has three important Attributes for this behaviour,
InstanceContextMode
ConcurrencyMode
SessionMode
Most time I use InstanceContextMode.PerSession
(Because Client 1 doesnt have access to the Variables in the Service of Client 2), ConcurrencyMode.Multiple
and SessionMode.Required
.
You can also specify how many Instances can be initialized, how many Concurrent Calls can be made and how many Session can be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With