WCF – Configuring Instance Management

Instance management refers to the way a service handles a request from a client. Instance management is set of techniques WCF uses to bind client request to service instance, governing which service instance handles which client request.
 
It is necessary because application will differ in their need for scalability, performance, durability, transaction and queued calls.
 
There are three instance modes in WCF:
  1. Per-Call instance mode
  2. Per-Session instance mode
  3. Singleton Instance Mode
 
Configuration:
−Instance mode can be configured using ServiceBehavior attribute. This can be specified at implementing the service contract as shown below.
 
[ServiceContract()]
public interface IPayRollService
{
[OperationContract]
double ProcessSalary();
 }
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class PayRollService:IPayRollService
{
public double ProcessSalary()
{
//Do something
}
}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s