Intro To Enterprise Services

1,141 views

Published on

Intro To Enterprise Services

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,141
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Intro To Enterprise Services

  1. 1. Introduction to Enterprise Services Orlando Moreno omoreno@hotmail.com 408.656.2498
  2. 2. Enterprise Services leverages the existing COM+ 1.0 services in Windows 2000 such as transactions, role-based security, queued components, object pooling and loosely-coupled events. In addition, COM+ 1.5, present in Windows XP/.NET Server extends the Enterprise Services framework by providing new features such as public/private components, application recycling, configurable isolation levels, and COM+ SOAP services. Any developer interested in creating highly scalable, robust and reliable applications in .NET MUST attend this session. This session will give an introduction to what these services are and how to use Enterprise Services in the .NET universe. 408.656.2498 omoreno@hotmail.com 2
  3. 3.  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 3
  4. 4.  The term Enterprise means different things for different people  Large number of users, scalability and throughput a must  Fewer users, with drastic spikes in load  Few users using many expensive resources  Mission critical, 24x7, zero down time  Sensitive information  Interoperate with a wide range of platforms  Where quality and productivity are top priority  Any application that is not a toy program 408.656.2498 omoreno@hotmail.com 4
  5. 5.  Set of component services designed to ease considerably developing Enterprise applications  The result of integrating COM+ into .NET  .NET assemblies mapped to COM+ applications 408.656.2498 omoreno@hotmail.com 5
  6. 6. .NET Enterprise Services  Activation  Queued components  Library  Security  Server  Authorization  Service  Authentication  Instance management  Identity  Pooling  Remote calls and Web  JITA Services  Transactions  Combination of the  Concurrency services management  Loosely coupled events 408.656.2498 omoreno@hotmail.com 6
  7. 7. Evolution of Enterprise Services  MTS 1.0 1996  MTS 2.0 1998  COM+ 1.0 2000  COM+ 1.5 2001  .NET Enterprise Services (1.0?) 2002  .NET Enterprise Services (2.0?) 2003 (?)  MTS and COM+ were bad technology monikers 408.656.2498 omoreno@hotmail.com 7
  8. 8. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 8
  9. 9. Serviced Components  Components using services are called Serviced Components  Must derive from Serviced Component  System. Enterprise Services  Cannot use static members/methods  Cannot have parameterized constructors  Should use interfaces (not have to)  Should use class libraries (not have to)  .NET integration with COM+ is better than COM/VS6.0 408.656.2498 omoreno@hotmail.com 9
  10. 10. Registering Assemblies  Can register using RegSvcs.exe  Can register dynamically  Can register programmatically 408.656.2498 omoreno@hotmail.com 10
  11. 11. Assemblies and Applications  Application can contain components from multiple assemblies Application 1 Application 2 comp A comp B comp C comp D comp comp comp comp comp A B C D E Assembly 1 Assembly 2 408.656.2498 omoreno@hotmail.com 11
  12. 12. Registering Assemblies  Can register using RegSvcs.exe  Can register dynamically  Can register programmatically 408.656.2498 omoreno@hotmail.com 12
  13. 13. Manual Registration  Use RegSvcs.exe  Loads and registers .NET assembly  Incompatible attributes detected at registration  Uses existing COM+ app, if exists, by default  Allows individual settings  /c to create new application – error if exists  Can specify app name or ID [assembly: ApplicationName("MyApp")] [assembly: ApplicationID("8BE192FA-57D0-49a0-8608-6829A314EEBE")] 408.656.2498 omoreno@hotmail.com 13
  14. 14. Dynamic Registration  Only .NET Clients can use, COM-based ones still must use RegSvcs.exe  Useful only if your components are self- describing through attributes (i.e. no additional config through COM+ services)  Must be a member of Admin group  Triggers dynamic registration based on version number 408.656.2498 omoreno@hotmail.com 14
  15. 15. Programmatic Registration  Manual and dynamic registration all use RegistrationHelper class.  You can manually generate code to auto- install/register your components  Please see MSDN documentation on RegistrationHelper 408.656.2498 omoreno@hotmail.com 15
  16. 16. Versioning  CLSID’s are still around  RegSvcs uses CLSID’s for components  Any change in component creates new CLSID by default using System.Runtime.InteropServices; [Guid("260C9CC7-3B15-4155-BF9A-12CB4174A36E")] //Specify CLSID [ProgId("My Serviced Component")] //Specify ProgID public class MyComponent :ServicedComponent {…}  Force CLSID despite breaking changes  Useful for development 408.656.2498 omoreno@hotmail.com 16
  17. 17. Demo – Component Creation 408.656.2498 omoreno@hotmail.com 17
  18. 18. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 18
  19. 19. Object Construction  Can override default object construction for various purposes  Override protected Construct method  Most often used to pass connection strings  Can use attributes to specify construction string 408.656.2498 omoreno@hotmail.com 19
  20. 20. Constructor String [ConstructionEnabled(Enabled = true,Default = “Default String")] public class MyComponent :ServicedComponent { public override void Construct(string connStr) { //do something } }  Use attribute to enable/disable construct string usage  Admin defaults will override in component services 408.656.2498 omoreno@hotmail.com 20
  21. 21. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 21
  22. 22. Application Activation Type  Can specify application activation type  Server or a library application  Default is library [assembly: ApplicationActivation(ActivationOption.Server)] //or [assembly: ApplicationActivation(ActivationOption.Library)]  ActivationOption.Service may be available in Win XP 408.656.2498 omoreno@hotmail.com 22
  23. 23. Activation and Instance Management  Pool per machine in server application  Pool per app-domain in library application 408.656.2498 omoreno@hotmail.com 23
  24. 24. Instance Management  Goal:  Provide scalable solution that enables objects to “scale” easily  Scalability defined as:  Many stateless objects, short lifetime with many clients (i.e. internet)  Fewer stateful objects, long lifetimes and with complex logic (i.e. intranet)  Topics discussed is not new to .NET/COM+ 408.656.2498 omoreno@hotmail.com 24
  25. 25. Instance Management  Defined as:  Managing access to expensive instances/objects and managing their lifetime  Object Pooling  Maintain a set of objects, or pool, to serve clients  Pool per object type  Just-In-Time Activation (JITA)  References object ONLY when methods are called 408.656.2498 omoreno@hotmail.com 25
  26. 26. Object Pooling  When to use?  Creation of object overhead becomes substantial  Limit access to set resource (i.e. db)  The object constructor does most of the work  Initializing variables  Acquiring connections  Retrieving information from files/network shares  Typically found in internet scenarios 408.656.2498 omoreno@hotmail.com 26
  27. 27. Object Pooling  Set the min pool size or the max pool size  Set the creation timeout  Time to wait for an object to become available from pool 408.656.2498 omoreno@hotmail.com 27
  28. 28. Object Pooling Client creates Get object from pool [Client calls a method] [GC] [no] Is it [yes] Execute Dispose() the method Return to the pool 408.656.2498 omoreno@hotmail.com 28
  29. 29. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 29
  30. 30. JITA  When to use?  Client doesn’t need to know particular object reference  Object instantiation is not expensive  Method calls are expensive  Consume many resources  Complex state machine  State management should be based on durable storage  Typically found in intranet scenarios 408.656.2498 omoreno@hotmail.com 30
  31. 31. Just In Time Activation (JITA) 1 Client calls a method on proxy, that delegates the call to the 2 object 3 When method returns, object indicates it can be deactivated 4 Interceptor release object, and NULLs its reference to it Client makes another call, the interceptor creates a new objec and delegates the call 4 1 4 1 Interceptor Server Client 3 Object 2 408.656.2498 omoreno@hotmail.com 31
  32. 32. Just In Time Activation (JITA) 1 Client calls a method on proxy, that delegates the call to the 2 object 3 When method returns, object indicates it can be deactivated 4 Interceptor release object, and NULLs its reference to it Client makes another call, the interceptor creates a new objec and delegates the call 4 4 Client Interceptor Server Object 408.656.2498 omoreno@hotmail.com 32
  33. 33. Attributes  ObjectPoolingAttribute [ObjectPooling(MinPoolSize = 3,MaxPoolSize = 10,CreationTimeout = 60)] public class MyComponent : ServicedComponent {}  JustInTimeActivationAttribute [JustInTimeActivation] public class MyComponent :ServicedComponent { public void MyMethod(long objectIdentifier) { GetState(objectIdentifier); DoWork(); SaveState(objectIdentifier); //inform .NET to deactivate the object upon method return ContextUtil.DeactivateOnReturn = true; } } 408.656.2498 omoreno@hotmail.com 33
  34. 34. Object Lifetime  Should always call Dispose() as soon as possible  Unmanaged resources: COM+ Metadata  Ensure maximal efficiency for object pools  For JITA:  [AutoComplete] does auto-deactivation after each method  Manually deactivate with ContextUtil. DeactivateOnReturn 408.656.2498 omoreno@hotmail.com 34
  35. 35. Demo – Object Pooling/JITA 408.656.2498 omoreno@hotmail.com 35
  36. 36. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 36
  37. 37. Single component/Single resource  I need to ensure (ACID) on one component and resource  Component responsible for enlisting resource  Manual Transactions are often good enough (generally more performant)  Doesn’t need Enterprise Services Client Obj Transaction DB 408.656.2498 omoreno@hotmail.com 37
  38. 38. Multiple Component, Single Resources  Scenario:  Multiple components enlisting single resource Transaction Client Obj Obj Obj DB 408.656.2498 omoreno@hotmail.com 38
  39. 39. Multiple Component, Single Resources  Scenario is complicated:  Resource should be enlisted just once  By whom? first to access it? first created?  How would components know all that?  Components can be on different machines  Transaction has to flow across machine boundary  One machine can crash, while the other continue processing  Each component can encounter error and abort  Only if they all succeed ask the resource to commit  Somebody has to collect the votes 408.656.2498 omoreno@hotmail.com 39
  40. 40. Multiple Components, Single Resource  The resource should be notified about the vote just once  But who knows what is the right thing to do?  Resource can still refuse to commit changes  .NET make this situation as easy as the previous one 408.656.2498 omoreno@hotmail.com 40
  41. 41. Multiple Components, Multiple Resources  Multiple components accessing multiple resources, all taking part in same transaction Client Transaction Obj Obj Obj DB DB DB 408.656.2498 omoreno@hotmail.com 41
  42. 42. Multiple Components, Multiple Resources  Multiple points of failure  Resources must be enlisted, and just once  Who keeps track of what resources are used?  Put that knowledge in your code ?  Components and resources ca be on different machines  Transaction has to flow across machine boundary  Each resource can encounter error with the requested changes and can abort the transaction  .NET Enterprise Services make this as easy as the first one 408.656.2498 omoreno@hotmail.com 42
  43. 43. Transactions and ES  Use attributes to control transaction options [Transaction(TransactionOption.Required)] public class ESClass : ServicedComponent {…}  Use ContextUtil for voting ContextUtil.MyTransactionVote = TransactionVote.Abort;  AutoComplete (de-activates JITA too) [Transaction(TransactionOption.Required)] public class ESClass : ServicedComponent { [AutoComplete] public SomeMethod(int a, int b) {…} } 408.656.2498 omoreno@hotmail.com 43
  44. 44. Demo – Transactions 408.656.2498 omoreno@hotmail.com 44
  45. 45. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 45
  46. 46. Role-Based Security  COM+ (ES) role-based security is different from .NET role-based security  .NET role is based on a Windows User Group  COM+ roles can be application specific and or attributed to interfaces/methods 408.656.2498 omoreno@hotmail.com 46
  47. 47. Role-Based Security  Security Identity – defined as the current windows user  Authentication  Verification of who the user claims to be  Verification of data integrity (COM+ does this via checksum/packet or encryption)  Authorization – i.e. access control  What does the user have access to? 408.656.2498 omoreno@hotmail.com 47
  48. 48. Role-Based Security  .NET Attributes  ApplicationAccessControlAttribute configures all settings on the security tab [assembly: ApplicationActivation(ActivationOption.Server)] [assembly: ApplicationAccessControl( true,//Authorization AccessChecksLevel=AccessChecksLevelOption.ApplicationComponent, Authentication=AuthenticationOption.Packet, ImpersonationLevel=ImpersonationLevelOption.Identify)] 408.656.2498 omoreno@hotmail.com 48
  49. 49. Assigning Roles to Component, Interface, Method  Use SecurityRole attribute [assembly: SecurityRole("Role1")] [assembly: SecurityRole("Role2")] [assembly: SecurityRole("Role3")] [SecurityRole("Role2")] interface IMyInterface { [SecurityRole("Role3")] void MyMethod(); } [SecurityRole("Role1")] [ComponentAccessControl] public class MyComponent : ServicedComponent, IMyInterface {} 408.656.2498 omoreno@hotmail.com 49
  50. 50. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 50
  51. 51. Queued Components  What are Queued Components?  A way of making asynchronous calls to (remote) object methods  Uses MSMQ as the transport layer  Allows for messaging based processes and business workflows  Allows for buffering of workloads and increased scalability  Supports transactions 408.656.2498 omoreno@hotmail.com 51
  52. 52. Queued Components  The Recorder – acts like client proxy  Lives on client  Converts method calls to MSMQ messages  The Player -- acts as stub to proxy  Translates MSMQ messages to method calls  The Listener – lives in component app-domain  Serves multiple components  One listener per application queue  Creates proper player object to retrieve messsages 408.656.2498 omoreno@hotmail.com 52
  53. 53. QC Architecture IMyInterface 6 Client Player My Component 1 5 4 IMyInterface MSMQ 3 Recorder Listener 2 ISomeInterface Player Some Note: There are actually 2 queues, Component one for the client and the other for the endpoint 408.656.2498 omoreno@hotmail.com 53
  54. 54. QC Attributes  ApplicationQueuingAttribute – tells RegSvcs.exe to create public queue support  InterfaceQueueAttribute – enables queuing support for interface  No support for in, in/out, retval IDL attributes  In .NET that means by value only 408.656.2498 omoreno@hotmail.com 54
  55. 55. 408.656.2498 omoreno@hotmail.com 55
  56. 56. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 56
  57. 57. Loosely-Coupled Events  COM+ or LCE events are used to de-couple components  COM+ provides subscriber/publisher filtering to control event delivery  Event notification can be uncoupled from client via QC 408.656.2498 omoreno@hotmail.com 57
  58. 58. Agenda  Overview to Enterprise Services  Registration/Deployment  Object Construction  Instance Management  Transaction  Role-based Security  Queued Components  Loosely-Coupled Events  Windows XP/.NET Server 408.656.2498 omoreno@hotmail.com 58
  59. 59. Windows XP/.NET Server  Private components – create components that are only accessable within the context of a COM+ application  Isolation Levels – control locking on a component level  Application Recyling – COM+ applications will recycle based on set parameters  Image Dumps  COM+ Soap Web Services 408.656.2498 omoreno@hotmail.com 59
  60. 60. VB.NET Upgrade Day  Tell your friends… 408.656.2498 omoreno@hotmail.com 60
  61. 61. 408.656.2498 omoreno@hotmail.com 61
  62. 62. Orlando Moreno omoreno@hotmail.com 408.656.2498 408.656.2498 omoreno@hotmail.com 62

×