Gateway system for realizing REST access service based on transaction middleware and realization method
Technical Field
The invention relates to the technical field of computer communication under an industrial Internet platform environment, in particular to a gateway system for realizing REST access service based on transaction middleware and a realization method thereof.
Background
The industrial Internet is an emerging state and application mode formed by deep fusion of a new generation of information technology and manufacturing industry, and realizes interconnection and intercommunication of an enterprise internal control system and a management information system, optimization of configuration of manufacturing resources and integrated sharing of data resources by constructing an open cloud platform which takes data as a core and is efficient in resource configuration and active in innovation.
The transaction middleware is a software system for providing application-oriented transaction for an industrial Internet platform. The system provides a development environment and a transaction processing platform for an application system through a distributed architecture, shields a heterogeneous environment and supports fast response of high concurrency processing.
The transaction middleware is widely applied to core online transaction systems in industries such as manufacturing industry, finance, traffic, communication, electric power, color, petrochemical industry and the like, and helps the enterprises to realize key business.
In the actual application process, due to performance, safety and other reasons, the transaction middleware often adopts a private protocol to carry out data communication, the client needs to link an application access interface provided by the server, and resource calling can be completed through multi-layer application protocol forwarding, so that the server cannot widely share the loaded application service through an industrial internet platform.
In order to overcome the defects of the existing functions, the invention provides a gateway system and a method for realizing REST access service based on transaction middleware, which can effectively improve the working efficiency of an application system.
By opening service resources through REST/HTTP software communication technology, a user can quickly and completely use remote application services through browser/server architecture, even if he does not have the expertise of a network, an operating system and an application programming interface, as long as he grasps a simple calling method.
The result shows that the gateway software system and the method thereof have practical significance for improving the use convenience of users and the speed and performance of service resource calling.
Meanwhile, by adapting to the REST service gateway, the domestic middleware has the capability of large-scale application of standard foreign similar excellent software products in terms of comprehensive functions, performance supporting capability, safety and the like.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide a gateway system for realizing REST access service based on transaction middleware and an implementation method thereof.
The gateway system for realizing REST access service based on transaction middleware provided by the invention comprises transaction middleware;
The transaction middleware adopts a distributed architecture and comprises an application interface layer, a service framework layer, a data access layer and a basic support layer from top to bottom;
The application interface layer is used for packaging interaction among different modules, services or systems in the transaction middleware in a standardized manner;
The service framework layer is used for providing a network communication mode for the transaction middleware and realizing information interaction with an external system.
The data access layer is used for processing various business data for the transaction middleware;
The basic support layer is used for providing various hardware, networks, operating systems and database servers for the data service resource processing platform and the scattered application clients related to the transaction middleware.
The service framework layer comprises a REST gateway, and the REST gateway is used for providing REST access service modes to realize information interaction with external systems.
Preferably, the REST gateway is a network software system based on REST architecture style and adopting the international open standard HTTP/1.1 protocol;
The REST gateway defines the operation mode of the resource by using a unified interface specification, identifies the resource position by using a unified resource identifier URI and performs data interaction by using a media type.
Preferably, the REST gateway comprises a listener and a gateway processor;
The listener transmits the socket connection handle to the gateway processor to realize the communication connection between the client and the gateway processor;
The client finishes network transmission of the request data through the HTTP protocol, the gateway processor transmits the application data contained in the request message to the application server for processing through inter-process communication, the application server returns response data after the service program is executed, the gateway processor obtains the response data and packages the response data into an HTTP response message, and the HTTP response message is encrypted through the SSL protocol and then replied to the client.
Preferably, the monitor is configured to monitor an HTTP/S protocol port and a UNIX domain socket port, and receive a connection between an external client and an internal gateway processor, respectively;
the monitor selects a gateway processor according to a random scheduling strategy or a lightest load strategy of load balancing, and transmits a client connection handle to the gateway processor, and the gateway processor performs data interaction with the client based on the client connection handle.
Preferably, the gateway processor comprises a connection management module, an information security processing module, an HTTP protocol processing module and an application data interaction module;
The connection management module is used for connecting the gateway processor and the monitor, establishing and managing the connection with the external client request, and simultaneously establishing association between the socket connection handle and the SSL layer and setting a data read-write event;
The information security processing module is used for encrypting and decrypting the messages transmitted by both communication parties based on the symmetric key;
the HTTP protocol processing module is used for analyzing and packaging HTTP/1.1 request and response messages;
the application data interaction module is used for reading the processed response data from the memory through an inter-process communication mechanism, packaging the response data into an HTTP response message, and then encrypting and replying to the client.
The gateway system implementation method for realizing the REST access service based on the transaction middleware comprises the steps of constructing the transaction middleware, wherein the transaction middleware adopts a distributed architecture and comprises an application interface layer, a service framework layer, a data access layer and a basic support layer from top to bottom;
The application interface layer is used for packaging interaction among different modules, services or systems in the transaction middleware in a standardized manner;
The service framework layer is used for providing a network communication mode for the transaction middleware and realizing information interaction with an external system.
The data access layer is used for processing various business data for the transaction middleware;
The basic support layer is used for providing various hardware, networks, operating systems and database servers for the data service resource processing platform and the scattered application clients related to the transaction middleware.
The service framework layer comprises a REST gateway, and the REST gateway is used for providing REST access service modes to realize information interaction with external systems.
Preferably, the REST gateway is a network software system based on REST architecture style and adopting the international open standard HTTP/1.1 protocol;
The REST gateway defines the operation mode of the resource by using a unified interface specification, identifies the resource position by using a unified resource identifier URI and performs data interaction by using a media type.
Preferably, the REST gateway comprises a listener and a gateway processor;
The listener transmits the socket connection handle to the gateway processor to realize the communication connection between the client and the gateway processor;
The client finishes network transmission of the request data through the HTTP protocol, the gateway processor transmits the application data contained in the request message to the application server for processing through inter-process communication, the application server returns response data after the service program is executed, the gateway processor obtains the response data and packages the response data into an HTTP response message, and the HTTP response message is encrypted through the SSL protocol and then replied to the client.
Preferably, the monitor is configured to monitor an HTTP/S protocol port and a UNIX domain socket port, and receive a connection between an external client and an internal gateway processor, respectively;
the monitor selects a gateway processor according to a random scheduling strategy or a lightest load strategy of load balancing, and transmits a client connection handle to the gateway processor, and the gateway processor performs data interaction with the client based on the client connection handle.
Preferably, the gateway processor comprises a connection management module, an information security processing module, an HTTP protocol processing module and an application data interaction module;
The connection management module is used for connecting the gateway processor and the monitor, establishing and managing the connection with the external client request, and simultaneously establishing association between the socket connection handle and the SSL layer and setting a data read-write event;
The information security processing module is used for encrypting and decrypting the messages transmitted by both communication parties based on the symmetric key;
the HTTP protocol processing module is used for analyzing and packaging HTTP/1.1 request and response messages;
the application data interaction module is used for reading the processed response data from the memory through an inter-process communication mechanism, packaging the response data into an HTTP response message, and then encrypting and replying to the client.
Compared with the prior art, the invention has the following beneficial effects:
1. The invention greatly improves the flexibility of the use of the client and ensures the accuracy of the process by adding the browser/server side architecture calling mode, wherein the browser/server side architecture calling mode refers to the mode that the client accesses the application program on the server through the browser. The core part of the architecture is a server which is responsible for processing all business logic and data access operations, and a client only needs to install a standard browser to interact with the server through a network to acquire required information or execute corresponding operations;
2. the domestic middleware can be used for standard foreign similar excellent software products in the aspects of functional comprehensiveness, performance supporting capability, safety and the like, wherein the throughput of a system under the same scene can be improved by ten percent, and the CPU use load rate is reduced by sixty percent in a comparable way;
3. By collecting the running experience of the similar excellent software abroad in the actual use process of the enterprise project, the running efficiency of the software, the user feedback and other problems are analyzed, and the functional optimization can be performed for domestic software in a targeted manner. For example, by analyzing the operation habit and common problems of a user, the use of the software and the logic processing function can be optimized, and the user experience and the overall performance of the software are improved;
4. The REST service gateway system successfully carries out engineering implementation after design, coding and comprehensive test, and all test indexes reach industry standards through the overall test of the system, thereby completely realizing the design target.
Drawings
Other features, objects and advantages of the present invention will become more apparent upon reading of the detailed description of non-limiting embodiments, given with reference to the accompanying drawings in which:
FIG. 1 is a system architecture diagram of transaction middleware.
Fig. 2 is a functional block diagram of the REST gateway.
Fig. 3 is a functional flow diagram of a listener module.
Fig. 4 is an event flow diagram of a gateway processor module infrastructure.
Fig. 5 is a diagram showing the configuration of the gateway processor module.
Fig. 6 is a flowchart of the SSL protocol establishing a secure channel based on a handshake protocol and a recording protocol.
Fig. 7 is an HTTP protocol processing parsing workflow diagram.
Detailed Description
The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the present invention, but are not intended to limit the invention in any way. It should be noted that variations and modifications could be made by those skilled in the art without departing from the inventive concept. These are all within the scope of the present invention.
Example 1
The gateway system for realizing REST access service based on transaction middleware provided by the invention comprises the following components:
The transaction middleware software system adopts a distributed architecture, which is an application interface layer, a service framework layer, a data access layer and a basic support layer from top to bottom, has distributed transaction processing and application communication functions, and provides various perfect services to build, run and manage the application system, as shown in fig. 1.
The application interface layer mainly comprises a client program, an application programming interface, a WEB browser, a third-party software tool and a management console. The management console is a user management interface that provides management and configuration functions for the administrator for application services.
The service framework layer comprises a monitor and a gateway system (comprising a private gateway and a REST gateway) which are responsible for processing external concurrent call connection and analyzing request data, and functional modules such as a BBS bulletin board, system management, an application server, transaction processing and running real-time library which are responsible for application interaction.
The data access layer is composed of application service programs written by users and is responsible for processing various business data.
The base support layer is responsible for supporting heterogeneous hardware, networks, operating systems, and database servers.
The application interface layer, the service framework layer, the data access layer and the basic support layer form an enterprise transaction middleware platform, so that developers can establish a cross-platform interoperable application system, and the unified and centralized data service resource processing platform and the independent and scattered application clients work cooperatively to jointly realize resource integrated management under an industrial Internet platform.
The gateway of the transaction middleware is a software system for realizing application layer protocol conversion, and is also an inlet and an outlet for information interaction with an external system. The private gateway adopts an enterprise private protocol to carry out data communication, and a client program invokes a specific application programming interface to finish the functions of connecting a gateway system, requesting service, processing business data, logging off connection and the like, so that the safety and privacy of the data are protected.
The REST gateway is a network software system based on REST architecture style and adopting international open standard HTTP (hypertext transfer protocol)/1.1 protocol. It uses a uniform interface specification to define the way the resource operates, uses a uniform resource identifier URI (Uniform Resource Identifier) to identify the resource location, uses media types (e.g., JSON, XML, etc.) for data interactions.
Through HTTP protocol, REST gateway can realize loose coupling based on data interaction between WEB browser, client program and server application service processing program, provides convenient, flexible and safe interface calling mode based on browser/server architecture in service frame layer, and possesses basic functions of load balancing, flow control, SSL encryption, authentication, etc.
The REST gateway is composed of a monitor and a gateway processor, as shown in fig. 2.
Each set of transaction middleware REST gateway system comprises a monitor and a plurality of gateway processors which are flexibly configured, so that the throughput of the system and the processing capacity of a server side can be effectively improved. The client program completes network transmission of the request data through HTTP protocol, the gateway processor efficiently transmits the application data contained in the request message to the application server for processing through inter-process communication, and after obtaining the response data, the response message is replied, and the main service functions are as follows:
1. and the client calls the REST resource address and establishes socket connection with the monitor.
2. The listener passes the socket connection handle to the gateway processor, after which the communication connection of the client is handled by the latter, and the listener is no longer involved.
3. The gateway processor is responsible for transmitting data at the TCP layer, decrypting and analyzing the HTTP request message through an upper SSL protocol, and obtaining application data.
4. The gateway processor delivers the data to the application server, which returns response data after execution by the service program.
5. The gateway processor obtains the response data, encapsulates the response data into an HTTP response message, and replies to the client after encrypting the HTTP response message through SSL protocol.
Wherein the listener module comprises:
The listener module is a network entry of the transaction middleware software system, and the client is connected with the REST gateway system through the listener. The listener is responsible for listening to the HTTP/S protocol port and the UNIX domain socket (Unix Domain Socket) port, receiving the connections of the external client and the internal gateway processor, respectively.
It selects a gateway processor according to a random scheduling policy of load balancing or a lightest load policy and transmits a client connection handle to the gateway processor, and the gateway processor performs data interaction with a client by the gateway processor, and the functional flow is shown in the following figure 3.
The "load balancing random scheduling policy" and the "lightest load policy" are the existing techniques that the trading middleware has implemented.
The gateway processor module includes:
the gateway processor responsible for resolving and packaging HTTP request and response messages is a core module of the REST gateway system and is also a basic component for realizing rapid calling of application services and processing of high-concurrency connection.
The bottom layer structure is based on an event driven software design mode, adopts a single thread asynchronous processing and concurrent connection Reactor (Reactor) programming model, uses an I/O multiplexing separator (select/poll function) of an operating system as a basic component of an event driven cycle, continuously checks signal events, timing events and I/O handle input/output read-write events, processes other ready network events by waiting for the timing events to be triggered, performs data dispatch, executes a callback function registered for the events in advance, notifies a service object of receiving data, and then completes protocol analysis of HTTP request messages.
The method combines an efficient inter-process communication mechanism in the transaction middleware, and reads response data processed by the application from the memory in a non-blocking manner while processing various network events in a serial and asynchronous manner, so that the efficient communication function of the system is realized.
The gateway processor module workflow is shown in fig. 4.
As shown in FIG. 5, the gateway processor module is composed of four functional sub-modules, namely a connection management sub-module, an information security processing sub-module, an HTTP protocol processing sub-module and an application data interaction sub-module.
The connection management sub-module is responsible for communication between the gateway processor and the monitor, establishes and manages connection with external client requests, establishes association between the socket connection handle and the SSL layer, sets data read-write events, and ensures stable and efficient data transmission. The functions are as follows:
1. Responsible for connecting, disconnecting, or reconnecting listeners.
2. And receiving the client socket connection handle forwarded by the listener.
3. An association is established between the connection handle and the SSL layer.
4. And interacting with the SSL layer, and establishing a secure connection through the information security processing sub-module exchange key and authentication.
5. And setting a callback function of the data read-write event for the socket connection handle.
6. The running state of the gateway processor is informed to the monitor in real time.
The information security processing sub-module comprises:
the secure sockets layer (Secure Sockets Layer, abbreviated SSL) protocol is an industrial internet privacy standard for encrypting and securing communications. The method is positioned between a TCP transmission layer and an application layer, and establishes a secure communication channel for both a client and a server.
The information security processing sub-module is responsible for encrypting and decrypting the actual transmission message for both communication parties. The key links of the information security accurate processing and the high-efficiency realization are checking certificates, identity verification, selection algorithms, negotiation protocol versions and keys.
First, the SSL protocol establishes a secure channel based on a handshake protocol and a recording protocol by the following steps, as shown in fig. 6.
And then, the information security processing sub-module encrypts and decrypts the data message by using the generated symmetric key, wherein the rules are as follows:
1. And the plaintext data which is decrypted by the SSL layer and arrives is informed to the HTTP protocol processing submodule for analysis by an event-driven callback mechanism.
2. The transmitted plaintext data is encrypted by the symmetric key of the SSL layer and then transmitted to the outside by the TCP transmission layer.
The mechanism realizes the data encryption function in the transmission process and provides safer and more reliable network communication service.
The HTTP protocol processing sub-module comprises:
The submodule is used for analyzing and packaging HTTP/1.1 request and response messages.
Firstly, it is responsible for analyzing the received plaintext data according to the HTTP/1.1 protocol requirement, removing the beginning line, the head field and the blank line ending symbol of the HTTP request message, collecting the subsequent data body according to the length field value of the head, and then delivering to the application server for processing, wherein the analyzing workflow is shown in figure 7:
The application service interaction submodule comprises:
the REST gateway adopts an FML32 (FIELD MANAGEMENT Language) format as a data structure for interaction between the gateway and the application server, and the dynamic construction problem of the application data structure is flexibly realized.
The application service interaction sub-module reads the processed response data from the memory through an inter-process communication mechanism, encapsulates the response data into an HTTP response message, encrypts the HTTP response message through the information security sub-module and replies to the client.
The invention also provides a gateway system for realizing the REST access service based on the transaction middleware, which can be realized by executing the flow steps of the gateway system realizing method for realizing the REST access service based on the transaction middleware, namely, the gateway system realizing method for realizing the REST access service based on the transaction middleware can be understood as a preferred implementation mode of the gateway system for realizing the REST access service based on the transaction middleware by a person skilled in the art.
Those skilled in the art will appreciate that the invention provides a system and its individual devices, modules, units, etc. that can be implemented entirely by logic programming of method steps, in addition to being implemented as pure computer readable program code, in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Therefore, the system and the devices, modules and units thereof provided by the invention can be regarded as a hardware component, and the devices, modules and units for realizing various functions included in the system can be regarded as structures in the hardware component, and the devices, modules and units for realizing various functions can be regarded as structures in the hardware component as well as software modules for realizing the method.
The foregoing describes specific embodiments of the present application. It is to be understood that the application is not limited to the particular embodiments described above, and that various changes or modifications may be made by those skilled in the art within the scope of the appended claims without affecting the spirit of the application. The embodiments of the application and the features of the embodiments may be combined with each other arbitrarily without conflict.