1 / 38

WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m

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

aolani
Download Presentation

WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected Syste m

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WCF INSTANCE MANAGEMENT Dhananjay Kumar MVP-Connected System

  2. 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 • This is useful to decide scalability, performance, durability, transactions and queued calls

  3. Instance Management

  4. Instance Management

  5. Instance Management

  6. Instance Management 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.

  7. Instance Management BEHAVIOR

  8. Instance Management SERVICE BEHAVIOR • This applies directly to service implementation class. • This affects all the endpoints. • This is used to configure service instance mode.

  9. Instance Management 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.

  10. Instance Management

  11. Instance Management Per Call Instance Mode Every Client request gets a new dedicated service instance. A service instance exists only when a client call is in progress.

  12. Instance Management Per Call Instance Mode

  13. Instance Management Per Call Instance Mode

  14. Instance Management Per Call Instance Mode Demo 

  15. Instance Management Per Session Instance Mode

  16. Instance Management Per Session Instance Mode

  17. Instance Management 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.

  18. Instance Management Configuring Session full Service

  19. Instance Management Behavior Facets The Behavior part is required, so that WCF will keep the Service Instance Context alive throughout the session.

  20. Instance Management 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.

  21. Instance Management Contract Facets In 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

  22. Instance Management Contract Facets • For this ServiceContract attribute having a property called SessionMode. • Type of property SessionMode is enumSessionMode. • It is inside namespace System.ServiceModel. • Property SessionMode is a public property.  • SessionModeenum is default to SessionMode.Allowed. • The Configured value of SessionMode is exposed to client in MetaData.

  23. Instance Management Contract Facets

  24. Instance Management 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.

  25. Instance Management SessionMode.Allowed

  26. Instance Management 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.

  27. Instance Management SessionMode.Required

  28. Instance Management SessionMode.Required

  29. Instance Management 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.

  30. Instance Management SessionMode.NotAllowed

  31. Instance Management SessionMode.NotAllowed DEMO 

  32. Instance Management Singleton Instance Mode

  33. Instance Management Singleton Instance Mode

  34. Instance Management 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.

  35. Instance Management Singleton Instance Mode

  36. Instance Management 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.

  37. Instance Management Singleton Instance Mode DEMO 

  38. Thank You. Dhananjay Kumar MVP-Connected System

More Related