Middleware Learning--Two steps (category)

Source: Internet
Author: User


In the previous article we introduced the origin of the middleware, definition and role, this article we continue to learn middleware, middleware product variety, according to the role of middleware in the system and the use of different technologies, we will be the middleware classification, we today learn more about the specific knowledge of the middleware.

category


middleware is divided into Remote Procedure Call middleware, data access middleware, message middleware, transaction ( trading ) processing middleware, distributed object Middleware .

Remote Procedure Calls middleware (RPC, remote Procedure call)

one of us to learn, the first to learn is the remote process call middleware, the remote procedure call is the program and the communication between programs, is the client application call on the remote server process, its basic idea is to keep the client (caller) and the server (called) program syntax, As if they were on the same machine . the programmer calls the remote procedure in the program as if it were a local procedure , starts the operation of the remote procedure, and then returns the result of the run to the local program. The remote procedure call is so simple that the specific invocation process is as follows:


before describing the remote invocation process, the first two concepts are Stub (stub) and Skeleton (skeleton).

Stub for clients, the main function is

1. Establish a connection between the client and the server

2, the client's high-level call statement is packaged as an underlying request message, this process is called column set (marshalling) in RPC

3. Wait for the server to return the reply message

4. Resolve the response message from the bottom of the server to the data that can be returned, which is called splitting (unmarshalling) in RPC

5. Transfer the return value to the client program


In this process, it is important to note that issues such as coding, byte order, etc.

skeleton for server-side, action stub The function is not much, the first solution and then in the column set, but skeleton in addition to the column set, the solution column, but also need to distinguish between the name of the process requested by the customer, and then assign the client's request (dispatch) to the correct process.

let's look at the following RPC the specific work process is:


1, the customer calls locally, the local customer placeholder program/reference/proxy, stub has the same process interface as the server

2, the stub will call the customer request processing, packaging, to the underlying communication mechanism (such as a socket) to send a request message; stub does not do any logical processing, just an intermediary

3, the client through the underlying communication mechanism, the message is transmitted to the server-side of the underlying communication mechanism

4. The server needs to parse the message partially to find out which server program the client wants to call.

5. The server architecture (Skeleton) parses the message, obtains the caller's arguments, and then calls the server program

6, the server program executes the corresponding process

7. The server program returns the results to skeleton

8, skeleton The result package, send a reply message to the underlying communication mechanism

9. The server-side communication mechanism sends the message to the client communication mechanism

10, the client node may also have multiple call points, the communication mechanism needs to partially parse the returned message, find out which client the message should be returned to, and send the message to the corresponding stub

11. The stub parses the result from the message and returns it to the client program


There are two implementations of remote calls, namely SUN of the RPC and Microsoft's RPC ,

SUN RPC (implemented on Solaris)

DCE (distributedcomputing Environment) RPC (unix,windows)

The remote invocation has the flexibility to be on its cross-platform, which not only can call the remote subroutine, but also can cross different operating system platforms, and programmers do not need to consider these details when programming.

RPC also has some drawbacks, mainly because RPC is generally used for communication between applications, and it uses synchronous communication, so it is more appropriate for smaller, simple applications because these applications typically do not require asynchronous communication. However, for some large applications, this is not a good way to do this, because at this time the programmer needs to consider network or system failure, processing concurrency, buffering, traffic control and process synchronization and a series of complex problems.

Data Access Middleware (Dm,database middleware)

In all of the middleware is the most widely used, the most mature technology. It is the software that connects the application and the database, allows to access the database products from different vendors through a single, well-defined interface, is to establish the interoperability mode of data application resources, and realizes the connection of the database in heterogeneous environment or the middleware of the file system.

Based on the database management system, the data access middleware provides the development support for the application Access database by implementing the connection of the database or the file system in the heterogeneous environment.

Data access middleware is the communication between the program and the database, the ability to read from the client or write to a database, which is physically located on a different machine, and these databases can be different database products;

One of the most typical examples is that ODBC,ODBC is a database-based middleware standard that allows applications to communicate with local or offsite databases and provides a range of API APIs, although in most cases these APIs are hidden in development tools and not directly used by programmers. A friend with practical programming experience knows that when writing a database program, simply add a data source in ODBC, and then you can use the data source directly in your own application without having to relate to the implementation principle and implementation mechanism of the target database. You don't even have to understand what API APIs the ODBC provides to your application.

However, in the database middleware processing model, the database is the core unit of information storage, the middleware completes the communication function, although it is flexible, but it is not suitable for some applications requiring high performance processing, because it requires a lot of data communication, and when the network fails, the system will not work properly. The so-called gain must have lost, this is the truth, the flexibility of the system to improve the processing performance at the cost of the reduction.

message Middleware (Mom,message oriented middleware)

because RPC is synchronous call, can not make asynchronous calls, message middleware in the application by passing messages to collaborate, is an asynchronous communication mode, so its motive is RPC The disadvantage of the call.

Message middleware provides middleware for applications to send and receive asynchronous message support. Message-based interaction provides a basic asynchronous programming pattern whereby a client can request a service by sending a message, and the client does not have to wait for the other to complete while the server is processing the request, and can perform other operations that notify the client when the server is finished. With the support of message middleware, applications can easily send and receive messages without having to worry about the specifics of the message exchange process.

The main function is to provide reliable and recoverable (if unexpected) message delivery between different network protocols, different operating systems, and different applications. At this point the app doesn't need instant messaging to get to the other person instantly. That is, the client puts the message in the queue, the server takes care of it at a convenient time, and if necessary, puts the result in the queue that is sent to the client.

Message Middleware works by:

1. The application communicates in a series of messages.

2. during message passing, the message is saved in the message queue in order to prevent the message from being lost.

3. The app sends the message to the queue associated with the receiver. The messaging mechanism guarantees that messages are delivered to the destination and delivered only once.

4. in the messaging process, there is no need to establish a connection between applications, and the sender only needs to put the message in the queue related to the receiver, without having to worry about whether the receiver is online.

5. the recipient only needs to extract the message from its own queue.

The advantage of message middleware is the ability to provide synchronous and asynchronous connections between the client and the server, and to transmit or store the message at any moment, which is why it is a step further than a remote procedure call. In addition, the message middleware does not consume large amounts of network bandwidth, can track transactions, and restore the system by storing transactions on disk to implement network failures. Of course, the message middleware does not support the transfer of program control compared to remote procedure calls, but this function is irrelevant to its advantages.

Message middleware is suitable for distributed environments that require reliable data transfer between multiple processes.

Message middleware can be used to block out the features between various platforms and protocols, communicate with each other, and achieve synergy between applications.

Message middleware enables distributed processing to run in a way that is offline, event-driven, etc., and suitable for use in e-commerce, mobile users, workflows, or other environments.

Because the message middleware is asynchronous, it is not suitable for real-time processing.

Transaction ( transaction ) processing middleware (Transaction processing MIDDLEWARE,TPM)

Transactions ( trading ) Processing Middleware is an environment platform for ensuring transaction integrity and data integrity in distributed, heterogeneous environments .

Transactions ( trading ) processing Middleware is middleware that provides transaction control mechanisms , designed specifically for online transaction processing systems. The online transaction processing system generally needs to deal with a large number of distributed transactions. Distributed transactions typically involve multiple databases and allow for heterogeneous databases, such as fund transfers between different banks. Therefore, distributed transactions need to deal with a large number of concurrent processes, involving the operating system, file system, programming language, data communication, database system, System management and application software, is a very difficult task. In this case, the application development is simplified through transaction processing middleware. It is responsible for dealing with the integrity of distributed transactions, concurrency control, load balancing and error recovery in the process of online transactions. It can combine its own transaction management function with the existing transaction management ability of database, and realize the global management of distributed transaction processing.

Generally speaking business ( trading ) Processing Middleware provides programmers with a transaction-processing API that programmers can use to write high-speed and reliable distributed applications .

Distributed transactions involve the updating of data from multiple nodes, and failure of communication between any node or node can lead to the failure of distributed transaction. Therefore, in order to guarantee the integrity of the transaction, the distributed transaction is usually committed using a two-phase commit protocol (Twophase commitment Protocol, referred to as 2PC).

Phase 1 (Preparation phase)

The TM asks if all RM is ready to submit.

Phase 2 (Submission phase)

TM Checks all RM answers, as long as one RM gives a negative answer, TM instructs all RM to rollback. Otherwise, the TM instructs all the RM to commit

In a two-phase commit, one master node is designated as the Transaction Coordinator (Coordiantor), and the other node is called the transaction contributor (participants). The facilitator has the discretion to submit or revoke the transaction, while the other participants are responsible for updating the local data and proposing to the facilitator the intention to revoke or commit the sub-transaction. Typically a node corresponds to a child transaction.

Distributed Object Middleware

Distributed Object Middleware is an object that is called on another system, and provides the middleware for component-based support. In the distributed and heterogeneous Network computing environment, all kinds of distributed objects are organically combined to complete the rapid integration of the system and realize object reuse. With the support of a variety of middleware, in the application software to the middleware corresponding functions, do not need the developer to implement their own, can directly use the middleware to quickly integrate their implemented functions into the application software.

PostScript

Knowledge about middleware This article is introduced here, the next article we continue the knowledge of middleware.

Middleware Learning--Two steps (category)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.