Arman Bimatov
Arman Bimatov

Reputation: 1829

Enforcing a separate session for WCF client

I'm testing my WCF service, and I would like to send two (virtually) parallel requests to my WCF service. However, my InstanceMode = PerSession and it's fine the way it is, I don't want to change the service behavior.

However, my question is - does creating two proxy client objects enforce separate sessions? Or is there something else that should be done to send the two requests via different client sessions? I created a sample C# console application to test this:

MyService client = new MyService();
MyService  client1 = new MyService();
client.GetResultsAsync();
client1.GetResultsAsync();

Upvotes: 1

Views: 144

Answers (1)

Bob2Chiv
Bob2Chiv

Reputation: 1968

It's a shame that your requirements prohibit using the primary feature that would solve this problem - namely InstanceMode = PerCall.

Per WCF Service Behaviors - Instance and Concurrency Management:

Using the default settings of InstanceMode = PerSession and ConcurrencyMode = ConcurrencyMode.Single then "it's easy to make a conclusion that every client has it's own session executed only on one thread per client."

Per Programming WCF Services - 3rd Edition Page 177:

"When the client creates a new proxy to a service configured as a sessionful service, the client gets a new dedicated service instance that is independent of all other instances of the same service"

Upvotes: 2

Related Questions