Different types of InstanceModes and ConcurrencyModes inside Indigo

Indigo has five different types of instances modes than be used inside the system.  The default liftetime, if none is specified, is PerCall.  They are:

  • PerCall

  • PrivateSession

  • SharedSession

  • Singleton

  • Well known

The PerCall lifetime means that each time a call comes into the system a new instance is created of the service and a new ServiceSite that is associated with it is created.  The second two types of instance lifetime only work when there is a session associated with the channel, a session is created when ReliableMessaging is enabled on the bindings.  The PrivateSession lifetime means the instance and site stick around for the entire duration of the session, so this usualy means the duration of the channel.  A SharedSession means that the endpoint reference to the service can be generated on the client side by using ResolveInstance().  This endpoint reference can then be passed onto other clients or other channels and used to reference the specific endpoint on the remote side.  A singleton means that there will only ever be one of the ServiceSite created on the remote side and this will be used for the entire duration of the servicehost. 

The well known lifetime is a variation on singleton where the instance is created before hand and passed into the ServiceHost as a specific instance when it is created.  This instance is then used in all cases where the instance is needed to be referenced.  A well known instance must have a [ServiceBehavior(InstanceMode = InstanceMode.Singleton)] set on the service.

If the InstanceMode is set to PrivateSession of SharedSession the system will throw an exception when you try and setup a binding on the service side that does not support a session.  They do not have a fall back behavior if the incoming channel does not contain a session and will cause an exception to be thrown on the client side.

Comments (0)

Skip to main content