Top Banner
WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP- Connected System
38

WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m

Feb 20, 2016

Download

Documents

aolani

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 Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

WCF INSTANCE MANAGEMENT Dhananjay Kumar

MVP-Connected System

Page 2: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

3

Instance Management

Page 4: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

4

Instance Management

Page 5: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

5

Instance Management

Page 6: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

7

Instance ManagementBEHAVIOR

Page 8: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

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

10

Instance Management

Page 11: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

Per Call Instance Mode

12

Instance Management

Page 13: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Per Call Instance Mode

13

Instance Management

Page 14: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Per Call Instance Mode

Demo

14

Instance Management

Page 15: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Per Session Instance Mode

15

Instance Management

Page 16: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Per Session Instance Mode

16

Instance Management

Page 17: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

Configuring Session full Service

18

Instance Management

Page 19: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

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

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

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

Contract Facets

23

Instance Management

Page 24: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

SessionMode.Allowed

25

Instance Management

Page 26: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

SessionMode.Required

27

Instance Management

Page 28: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

SessionMode.Required

28

Instance Management

Page 29: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

SessionMode.NotAllowed

30

Instance Management

Page 31: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

SessionMode.NotAllowed

DEMO

31

Instance Management

Page 32: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Singleton Instance Mode

32

Instance Management

Page 33: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Singleton Instance Mode

33

Instance Management

Page 34: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

Singleton Instance Mode

35

Instance Management

Page 36: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

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

Singleton Instance Mode

DEMO

37

Instance Management

Page 38: WCF INSTANCE  MANAGEMENT              Dhananjay Kumar                        MVP-Connected Syste m

Thank You.

Dhananjay KumarMVP-Connected System