wcf instance management dhananjay kumar mvp-connected syste m
DESCRIPTION
WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m. Instance Management. Instance Management is a technique to decide, which SERVICE INSTANCE handles which CLIENT REQUEST and when? This is a service side implementation detail - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/1.jpg)
WCF INSTANCE MANAGEMENT Dhananjay Kumar
MVP-Connected System
![Page 2: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/2.jpg)
Instance Management is a technique to decide, which SERVICE INSTANCE handles which CLIENT REQUEST and when?
This is a service side implementation detail This is useful to decide scalability,
performance, durability, transactions and queued calls
2
Instance Management
![Page 3: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/3.jpg)
3
Instance Management
![Page 4: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/4.jpg)
4
Instance Management
![Page 5: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/5.jpg)
5
Instance Management
![Page 6: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/6.jpg)
BEHAVIOR Instance management is a service side activation
implementation detail that should not get manifested to the client. WCF achieve this by BEHAVIOR.
A Behavior is a local attribute of service that does not affect its communication patterns.
Client does not aware of the Behavior. Service does not manifest behavior in binding or
metadata. Practically Behaviors are WCF classes. These are used at the runtime operations.
6
Instance Management
![Page 7: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/7.jpg)
7
Instance ManagementBEHAVIOR
![Page 8: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/8.jpg)
SERVICE BEHAVIOR
This applies directly to service implementation class.
This affects all the endpoints. This is used to configure service instance mode.
8
Instance Management
![Page 9: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/9.jpg)
OPERATION BEHAVIOR
This is used to configure operation behavior. This affects only implementation of a particular
operation. This could apply only to method that implements
contract operation. This is not applied to the contract definition itself.
9
Instance Management
![Page 10: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/10.jpg)
10
Instance Management
![Page 11: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/11.jpg)
Per Call Instance ModeEvery Client request gets a new dedicated service instance. A service instance exists only when a client call is in progress.
11
Instance Management
![Page 12: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/12.jpg)
Per Call Instance Mode
12
Instance Management
![Page 13: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/13.jpg)
Per Call Instance Mode
13
Instance Management
![Page 14: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/14.jpg)
Per Call Instance Mode
Demo
14
Instance Management
![Page 15: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/15.jpg)
Per Session Instance Mode
15
Instance Management
![Page 16: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/16.jpg)
Per Session Instance Mode
16
Instance Management
![Page 17: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/17.jpg)
Per Session Instance Mode WCF can maintain a logical session between a client and service. The service instance remains in the memory throughout the
session. The client session is per service endpoint per proxy.
17
Instance Management
![Page 18: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/18.jpg)
Configuring Session full Service
18
Instance Management
![Page 19: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/19.jpg)
Behavior FacetsThe Behavior part is required, so that WCF will keep the
Service Instance Context alive throughout the session.
19
Instance Management
![Page 20: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/20.jpg)
Behavior Facets InstanceContextMode.PerSession is default value for InstanceContextmode
property. The session terminates when client closes the proxy. Proxy has to notify the service that session has been closed and service calls the
Dispose () method on worker thread.
20
Instance Management
![Page 21: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/21.jpg)
Contract FacetsIn order to create all messages from a particular client to a particular instance WCF needs to identify the client and this is done by TRANSPORT SESSION
21
Instance Management
![Page 22: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/22.jpg)
Contract Facets
For this ServiceContract attribute having a property called SessionMode. Type of property SessionMode is enum SessionMode. It is inside namespace System.ServiceModel. Property SessionMode is a public property. SessionMode enum is default to SessionMode.Allowed. The Configured value of SessionMode is exposed to client in MetaData.
22
Instance Management
![Page 23: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/23.jpg)
Contract Facets
23
Instance Management
![Page 24: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/24.jpg)
SessionMode.Allowed When the SessionMode is configured with SessionMode.Allowed, transport session are allowed but not
enforced. The Behavior of service will depend upon behavior configuration and binding.
24
Instance Management
![Page 25: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/25.jpg)
SessionMode.Allowed
25
Instance Management
![Page 26: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/26.jpg)
SessionMode.Required SessionMode.Required value restricts to use Transport level session. If a contract is configured as SessionMode.Required with a service end point who's binding does not
maintain a Transport level session a Run time error will encountered at loading of service.
26
Instance Management
![Page 27: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/27.jpg)
SessionMode.Required
27
Instance Management
![Page 28: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/28.jpg)
SessionMode.Required
28
Instance Management
![Page 29: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/29.jpg)
SessionMode.NotAllowed This disallows the use of Transport session. Regardless of the service configuration, when SessionMode.NowAllowed is configured at contract, the service will always behave as Per-call
service.
29
Instance Management
![Page 30: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/30.jpg)
SessionMode.NotAllowed
30
Instance Management
![Page 31: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/31.jpg)
SessionMode.NotAllowed
DEMO
31
Instance Management
![Page 32: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/32.jpg)
Singleton Instance Mode
32
Instance Management
![Page 33: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/33.jpg)
Singleton Instance Mode
33
Instance Management
![Page 34: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/34.jpg)
Singleton Instance Mode
The Singleton Service Instance created only once. It created when the service host is created. It lives forever. It got disposed only when host shuts down. Singleton service instance does not require client to maintain any logical session. It does not required to use binding that supports transport level session.
34
Instance Management
![Page 35: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/35.jpg)
Singleton Instance Mode
35
Instance Management
![Page 36: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/36.jpg)
Singleton Instance Mode
Having scalability problem. All requests to service will run on different worker thread, so it will cause synchronization problem. Only one client could have access to singleton service instance at a time. It will decrease throughput of the service. Responsiveness is very low Singleton Service instance should only be used, when no other options are available. For instance Global Log Book, Single Communication Port etc.
36
Instance Management
![Page 37: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/37.jpg)
Singleton Instance Mode
DEMO
37
Instance Management
![Page 38: WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m](https://reader033.vdocument.in/reader033/viewer/2022051420/56816003550346895dcf02b5/html5/thumbnails/38.jpg)
Thank You.
Dhananjay KumarMVP-Connected System