Topic2 Understanding Middleware


Published on

Published in: Technology, Business
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Topic2 Understanding Middleware

  1. 1. Middleware Sanjoy Sanyal (Tech for NonGeek)
  2. 2. Middleware <ul><li>Middleware facilitates and manages the interaction between applications across heterogeneous computing platforms </li></ul><ul><li>Three different aspects: </li></ul><ul><ul><li>Middleware in sub-systems that are physically close to each other </li></ul></ul><ul><ul><li>Middleware in systems that are completely different applications </li></ul></ul><ul><ul><li>Middleware in Web applications </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek) In this section we are going into detail on the first aspect
  3. 3. Understanding Middleware <ul><li>Offers programming abstractions that hides the complexities of bridging between heterogeneous platforms </li></ul><ul><li>Middleware implements the functionality of the abstraction </li></ul>Sanjoy Sanyal (Tech for NonGeek) Remote Procedure Call Sockets TCP/UDP IP A simple example Remote Procedure Call: Hides communication details behind a procedure call Sockets: operating system level interface to the underlying communication protocols Underlying communication protocol
  4. 4. Types of Middleware <ul><li>RPC-based systems </li></ul><ul><ul><li>Infrastructure to transform procedure calls to remote procedure calls </li></ul></ul><ul><li>TP monitors </li></ul><ul><ul><li>At a basic level, RPC with transactional capability </li></ul></ul><ul><li>Object brokers </li></ul><ul><ul><li>Platforms to support invocation of remote objects </li></ul></ul><ul><li>Object monitors </li></ul><ul><ul><li>Convergence of TP Monitors and Object brokers in a OO scenario </li></ul></ul><ul><li>Message-oriented middleware </li></ul><ul><ul><li>Queuing systems for asynchronous interactions </li></ul></ul><ul><li>Message brokers </li></ul><ul><ul><li>Application logic to transform and filter messages in queues </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  5. 5. Developing Distributed Applications with RPC Sanjoy Sanyal (Tech for NonGeek) Client Code Client Stub Language specific call interface Development Environment IDL Compiler IDL Sources Interface headers IDL Server Stub Language specific call interface Server Code Client Process <ul><ul><li>Step 1: Define the interface for the procedure. This is done using an interface definition language (IDL). The IDL provides an abstract representation of the procedure in terms of input and output parameters. </li></ul></ul><ul><ul><li>Step 2: Compile the IDL description. </li></ul></ul><ul><ul><li>Client Stub is a piece of code compiled and linked to client </li></ul></ul><ul><ul><li>When a client makes a remote call the stub takes care of: </li></ul></ul><ul><ul><li>Locating the server ( binding) </li></ul></ul><ul><ul><li>Formatting the data ( Marshalling and serilaizing ) </li></ul></ul><ul><ul><li>The stub is a proxy for the procedure implemented by the server </li></ul></ul><ul><ul><li>Server Stub implements the Server side of the invocation </li></ul></ul><ul><ul><li>Receives the invocation from the client stub </li></ul></ul><ul><ul><li>Formats the data ( unMarshalling and de- serilaizing ) </li></ul></ul><ul><ul><li>Invokes the actual procedure call at the server </li></ul></ul><ul><ul><li>Forwards the results to the client stub </li></ul></ul>
  6. 6. Binding in RPC <ul><li>Client creates a local association ( handle to) a server </li></ul><ul><li>Static Binding </li></ul><ul><ul><li>Client stub is hardcoded to already contain the handle of the server where the procedure lies </li></ul></ul><ul><li>Dynamic binding </li></ul><ul><ul><li>Uses a name and a directory server to resolve server addresses based on signature of procedures </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek) Static Binding Dynamic Binding Simple and Efficient Tightly Coupled Not possible to use dynamic load balancing The directory server can assist in load balancing Decoupling leads to flexibility There is additional cost of implementation
  7. 7. RPC functioning with Dynamic binding Sanjoy Sanyal (Tech for NonGeek) Client Procedure Call Client Stub Bind Marshal Serialize Client Process Communication Module Name and directory service (binder) Query for server implementing the procedure Address of server Server Procedure Server Process Server Stub Register Un-marshal De-serialize Receive Dispatch Communication Module Register server and procedure
  8. 8. Asynchronous Extension to RPC <ul><li>Conventional RPC uses a synchronous, procedural call </li></ul><ul><li>Asynchronous RPC allows the client thread not to be blocked </li></ul><ul><ul><li>The communication handle returns control to the client program immediately after sending request </li></ul></ul><ul><li>How this works? </li></ul><ul><ul><li>The stub provides two entry points – one to invoke the procedure and one to obtain the results of the invocation </li></ul></ul><ul><ul><li>The stub extracts the input parameters from a client call and returns control to client </li></ul></ul><ul><ul><li>The stub makes a call to server and waits for a response </li></ul></ul><ul><ul><li>Later the client makes a second call for the resuts </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  9. 9. RPC Middleware Extension: DCE <ul><li>Distributed Computing Environment (DCE) provided by the Open Software Foundation (OSF) </li></ul><ul><li>Provides RPC with additional services: </li></ul>Sanjoy Sanyal (Tech for NonGeek) Additional Service Description Cell directory server Sophisticated name and directory server used to create and manage RPC domains that can exist over the same network Time Service Provides mechanisms for clock synchronization across all nodes Thread service Support to thread and mutiple processors Distributed File Service Support to sharing of data files Security Service Support for authentication and secure communication
  10. 10. TP Monitors <ul><li>For long the dominant form of middleware </li></ul><ul><li>Implementations: </li></ul><ul><ul><li>IBM (CICS), BEA (Tuxedo), Microsoft (MTS) </li></ul></ul><ul><li>Main goal is to support execution of distributed transactions </li></ul><ul><ul><li>Here there are > 1 entity and > 1 procedure calls </li></ul></ul><ul><li>Conventional RPC treats the procedure calls (wrongly) as independent </li></ul><ul><li>TP monitors extend the RPC protocol with the ability to wrap a series of RPC invocations into a transaction so if… </li></ul><ul><ul><li>… group of procedure calls is committed all have been </li></ul></ul><ul><ul><li>… group of procedure calls is aborted , as if is that all have been </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  11. 11. TP Monitors: How it works? <ul><li>Procedure calls enclosed within transactional brackets (BOT & EOT) are treated as one unit. </li></ul><ul><li>A transaction management module coordinates interaction between clients and servers </li></ul>Sanjoy Sanyal (Tech for NonGeek) <ul><ul><li>Seq. 1: When it encounters a BOT, the Client Stub contacts the transaction manager to create a transactional identifier and a transactional context for the sequence of calls. </li></ul></ul><ul><ul><li>Seq. 2: When the Client calls one of the Servers, the server stub extracts the transactional identifier and notifies the transaction manager that it is participating and forwards the call as a normal call. </li></ul></ul><ul><ul><li>Seq. 3: The same is done when the client invokes a second server </li></ul></ul><ul><ul><li>Seq. 4: When EOT is reached, the client stub notifies that transaction manager </li></ul></ul><ul><ul><li>Seq. 5: The transaction manager initiates a two-phase commit (2PC) protocol to determine the outcome of the transaction </li></ul></ul><ul><ul><li>Seq. 6: The transaction manager informs the client stub once the protocol terminates </li></ul></ul>
  12. 12. 2 PC Protocol <ul><li>Standard mechanism for guaranteeing atomicity in distributed information systems </li></ul><ul><li>First a part of CICS and then standardized by the Open Group within the X/Open Specification </li></ul>Sanjoy Sanyal (Tech for NonGeek) <ul><ul><li>The transaction manager executes the commit in two phases: </li></ul></ul><ul><ul><li>Phase 1: It contacts each server involved in the transaction by sending a prepare to commit message asking whether the server is ready to execute a commit </li></ul></ul><ul><ul><li>By saying that it is ready to commit a server guarantees that it will be able to commit the procedure even if failures occur subsequently </li></ul></ul><ul><ul><li>If the server could not complete the transaction it replies abort </li></ul></ul><ul><ul><li>Phase 2: The transaction manager examines all the replies received and if all of them are “ready to commit” it instructs each server to commit the changes performed </li></ul></ul><ul><ul><li>If there is at least one abort (or a lack of responses) it instructs all servers to abort the transaction </li></ul></ul><ul><ul><li>Fault tolerance is achieved through logging (writing the state of the protocol to persistent storage) </li></ul></ul>
  13. 13. Transactional RPC Sanjoy Sanyal (Tech for NonGeek) Client 1.BOT 4. Procedure call 10. EOT Client Stub 2. Register txn and create context 5. Add txn id and context to call 11. Request commit 14. Confirm termination Client Process Server 9. procedure Server Process Server Stub 6. Extract context and txn id 7. Register server for txn 13. Participate in 2PC Register server and procedure Transaction manager 3. Create txn id Register txn Regsiter txn for client Return txn id 8. Lookup txn id Run 2PC Notify client of outcome 8. Lookup txn id Register server for txn
  14. 14. TP-lite and heavy <ul><li>TP-heavy systems provide rich tools and middleware functionality </li></ul><ul><li>TP-lite systems are implemented as a 2-tier system to provide an RPC interface to databases </li></ul><ul><ul><li>Done using stored procedures where application logic is written within the scope of the database </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  15. 15. TP Monitor Functionality Sanjoy Sanyal (Tech for NonGeek) Functionality Description RPC Support IDLs, name and directory servers, security and authentication, stub compilers …. Programming abstraction deal with T-RPC BOT, EOT, and may include additional callback and workflow mechansisms (on commit, on abort) Transactional Manager for implementing TRPC Transaction Manager functionality: logging, recovery, locking Monitor Systems Scheduling threads, assigning priorities, load balancing, replication, starting and stopping components Run-time environment Provides the resources and services applications may need (transactional services, security services, transactional file systems…) Specialized Components Ranging from proprietary protocols for interacting with mainframes to persistent queuing systems for asynchronous interaction Tools For installing, managing and monitoring the performance of all components
  16. 16. Object Brokers <ul><li>Middleware infrastructure that support the development of distributed object-oriented applications </li></ul><ul><li>CORBA (Common Object Request Broker Architecture) is the most common example </li></ul><ul><ul><li>Developed in the early 1990s by the Object Management Group </li></ul></ul><ul><li>Distributed Component Object Model (DCOM) and COM+ specific to Microsoft is another example </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  17. 17. CORBA: System Architecture Sanjoy Sanyal (Tech for NonGeek) Object Request Broker financials Supply chain distributed documents information management systems management Vertical facilities horizontal facilities CORBA facilities naming transactions events lifecycle time relationships properties licensing trader concurrency query security startup externalization collection persistence User Defined Objects
  18. 18. How CORBA works <ul><li>Objects declare their interface so that clients are aware of the methods it provides </li></ul><ul><li>Mechanisms used are similar to RPC and support OO concepts such as inheritance/polymorphism </li></ul><ul><li>IDL compiler generates a stub and a skeleton which hide the distribution </li></ul><ul><ul><li>Stub is a proxy object that makes method calls in the client look like they are local </li></ul></ul><ul><ul><li>Skeleton similarly shields the server object </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  19. 19. Dynamic Service Selection and Invocation <ul><li>The IDL compiler statically generates a stub specific to a service interface </li></ul><ul><li>CORBA allows client applications to dynamically discover new objects, retrieve their interfaces and construct invocations of this object on the fly even if no stub has been generated and linked to the client </li></ul><ul><li>However, this is not used as the client object must understand service properties which requires a shared ontology between clients and service providers </li></ul>Sanjoy Sanyal (Tech for NonGeek) However, we will quickly learn how this is possible
  20. 20. Dynamic Service Selection and Invocation: How? <ul><li>To dynamically construct a method invocation: interface repository & dynamic invocation interface components </li></ul><ul><li>To identify services needed by the client: Naming and Trader Services </li></ul>Sanjoy Sanyal (Tech for NonGeek) Interface Repository Dynamic Invocation Interface Stores IDL definitions for all objects known to the ORB Applications can access the repository to browse, edit or delete IDL interfaces Provides operations such as get_interface and create_request that can be used by clients to browse the repository and dynamically construct the method invocation Naming Service Trading Service Allows for retrieval of object references based on the name of the service needed Clients are able to look for objects implementing a certain interface (Purchasing books) Allows for retrieval of services based on their properties Clients are able to look for objects which have specified values (selling history or IT books)
  21. 21. How CORBA works Sanjoy Sanyal (Tech for NonGeek) Object Request Broker Dynamic Invocation Interface Application object (client) IDL of service provider stub Application object (client) IDL compiler (client side) IDL compiler (server side) Application object (service provider) skeleton Interface repository
  22. 22. CORBA: Encapsulation & Advantages <ul><li>Client and server objects need not be implemented in the same language or run on the same OS </li></ul><ul><li>Neither needs to know in which language/environment the object has been implemented </li></ul><ul><li>All a client needs to know is the Server’s IDL specification </li></ul><ul><ul><li>All method calls flow thru the ORB where invocation parameters are converted into a common data format </li></ul></ul><ul><ul><li>The data parameters are converted back at the skeleton </li></ul></ul><ul><li>This allows development flexibility on both client and server sides </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  23. 23. TP Monitors <ul><li>Represents the convergence of TP monitors and Object Brokers </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  24. 24. Message Oriented Middleware <ul><li>Supports asynchronous forms of interaction </li></ul><ul><li>Evolved from asynchronous versions of RPC and queuing systems of TP monitors </li></ul><ul><li>Well known MPM platform: </li></ul><ul><ul><li>IBM WebSphere, Microsoft MSMQ, WebMethods Enterprise, CORBA messaging service </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  25. 25. MOM Basics <ul><li>Message is a structured data set characterized by: </li></ul><ul><ul><li>A Type (typically XML) </li></ul></ul><ul><ul><li>A set of <name,value> pairs </li></ul></ul><ul><li>Clients and service providers communicate by exchanging messages </li></ul>Sanjoy Sanyal (Tech for NonGeek) Client Service Provider Message-Oriented Middleware (MOM) Client Service Provider Message-Oriented Middleware (MOM) Client sends a message The service provider servers the request by another message Note : to the MOM all objects are alike the distinction between clients and service providers depends on the context
  26. 26. Message Queues <ul><li>Messages sent by the MOM clients are placed in a queue </li></ul><ul><li>When the recipient is ready to process a new message it invokes the MOM to retrieve the first message in the queue </li></ul><ul><li>Advantages: </li></ul><ul><ul><li>Recipients do not have to continuously listen for new messages and process them right away – they do so when they can </li></ul></ul><ul><ul><li>More robust to failures – if the application is down or unable to send messages these will be stored in the queue </li></ul></ul><ul><ul><li>Queues can be shared across applications – if they provide the same service they can be used for load balancing </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  27. 27. Interacting with a Message Queuing System <ul><li>Queuing Systems provide an API that can be invoked to send messages or to wait for and receive messages </li></ul><ul><li>Sending message is typically not a blocking operation receiving is </li></ul><ul><li>Java Programmers use a standard API to interact with MOM systems: Java Message Service (JMS) </li></ul>Sanjoy Sanyal (Tech for NonGeek) In JMS each message is characterized by: A header, which includes meta data like the message type, expiration, priority Optional properties that extend the haeder metadata attributes for example to support compatibility with specific JMS implementations A body which includes the application-specific information Senders (receivers) first bind to a queue and then start sending (receiving) messages
  28. 28. Transactional Queues <ul><li>Transactional queuing is also called reliable queuing </li></ul><ul><li>The MOM ensures that once a message is sent: </li></ul><ul><ul><li>it will be eventually delivered once and only once to the intended recipient (even if the MOM goes down) </li></ul></ul><ul><ul><li>Messages are stored in a persistent storage </li></ul></ul><ul><li>Can be used to overcome failure situations: </li></ul><ul><ul><li>A set of message retrievals and notifications are bundled within an atomic unit of operation (all or nothing) </li></ul></ul><ul><ul><li>Messages within the atomic unit are maintained by MOM and made visible for delivery only on completion of the entire operation </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  29. 29. CORBA Architecture: Explained Sanjoy Sanyal (Tech for NonGeek) Component Description Object Request Broker Provides basic object interoperability functions CORBA Services Provide functionality commonly needed by most objects such as persistence, lifecycle management and security Accessible thru a standardized API CORBA facilities Provide higher level services needed by applications - Horizontal facilities: document management, internationalization, support for mobile agents - Vertical facilities: services specific to a market vertical (healthcare, education….)
  30. 30. Summary <ul><li>Middleware Offers programming abstractions that hides the complexities of bridging between heterogeneous platforms </li></ul><ul><li>Middleware implements the functionality of the abstraction </li></ul><ul><li>RPC provides basic form of distribution </li></ul><ul><li>TP monitors extended RPC to become the dominant form of middleware </li></ul><ul><li>Object brokers tried to standardize middleware platforms in a OO environment (superseded by J2EE and .NET) </li></ul><ul><li>Queuing systems evolved into MOM middleware to cope with the demands of cluster architecture and enterprise integration applications </li></ul><ul><li>(the material in this topic is based on Web Services: Concepts, Architectures and Applications by Alonso, Casati, Kuno, Machiraju) </li></ul>Sanjoy Sanyal (Tech for NonGeek)