CN113242221B - Protocol conversion method and protocol conversion device based on http micro-service gateway - Google Patents

Protocol conversion method and protocol conversion device based on http micro-service gateway Download PDF

Info

Publication number
CN113242221B
CN113242221B CN202110472605.0A CN202110472605A CN113242221B CN 113242221 B CN113242221 B CN 113242221B CN 202110472605 A CN202110472605 A CN 202110472605A CN 113242221 B CN113242221 B CN 113242221B
Authority
CN
China
Prior art keywords
protocol
http
information
micro
dubbo
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110472605.0A
Other languages
Chinese (zh)
Other versions
CN113242221A (en
Inventor
潘建波
吴红
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Original Assignee
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Happly Sunshine Interactive Entertainment Media Co Ltd filed Critical Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority to CN202110472605.0A priority Critical patent/CN113242221B/en
Publication of CN113242221A publication Critical patent/CN113242221A/en
Application granted granted Critical
Publication of CN113242221B publication Critical patent/CN113242221B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a protocol conversion method and a protocol conversion device based on an http micro-service gateway, comprising the following steps: a, a micro service gateway acquires and caches registered dubbo metadata information; b, after receiving the json-format http protocol request, the micro service gateway finds corresponding dubbo metadata information according to parameter information in the http protocol request; c, the micro service gateway analyzes json object information to byte buffer binary stream of the session 2 protocol of a java basic data type according to the found dubbo metadata information and a json object in the http protocol request; d, the micro service gateway acquires provider registered by the registration information, and analyzes the received byte buffer binary stream information of the session 2 protocol into character strings in a json format; and E, returning the character string in the json format of the http protocol. The invention can effectively improve the calling universality between the front end, the back end and each service and between languages, quickly provide the service protocol to the front end and the service caller and effectively solve the calling problem between multiple languages.

Description

Protocol conversion method and protocol conversion device based on http micro-service gateway
Technical Field
The invention particularly relates to a protocol conversion method and a protocol conversion device based on an http micro-service gateway.
Background
At present, services of various companies at home and abroad are started to be micro-serviced for quick iterative effective iterative services, wherein the most important part is a micro-service gateway and various open-source micro-service gateways exist, but at present, protocol conversion is mainly based on interface support of the micro-service and generic protocol calling.
At present, a common mode of front-end application (APP, WEB pages, H5 and various applets) and back-end interaction of the application is to carry out data interaction by a json format http protocol, most back-end services adopt a micro-service architecture, a business service part adopts the dubbo micro-service architecture in the process of technical transformation, and the dubbo micro-service architecture adopts a proprietary dubbo protocol to carry out interprocess communication. However, when cross-language and cross-platform calls are involved, the dubbo protocol cannot be supported or the supporting difficulty is high, so that the problem that the dubbo protocol cannot be used occurs.
A schematic diagram of the conventional micro-service gateway-based conversion of the dubbo protocol into the http protocol is shown in fig. 1. The existing conventional method for solving the conversion of the dubbo protocol by the micro service gateway mainly comprises two methods: one is an interface for directly outputting an http protocol at mvc in an application layer, and in such a case, each provided dubbo interface needs to provide a corresponding provider interface to provide an interface of the http protocol; the other method is to adopt generalized calling to convert the json character string into map, strictly transmit according to the pojo attribute, serially call the remote service, deserialize the remote service again, analyze the remote service into map, analyze the remote service into javabean, call the method, return the javabean, convert the method into map, serialize the method and return the gateway, deserialize the gateway, analyze the gateway into map, and return the json character string. In calling, because a large amount of temporary objects are needed, the memory requirement is large, the performance is difficult to achieve the best, and meanwhile, the server side adds a layer of map → pojo conversion to the generalization request and sacrifices the original performance of the dubbo.
Disclosure of Invention
The invention aims to provide a protocol conversion method and a protocol conversion device based on an http micro service gateway, aiming at the defects of the prior art, and the method and the device are used for solving the problem of unified and commonalization of a protocol so as to rapidly issue a service and solve the problem of protocol unsupported when the service is called; the invention can effectively improve the calling universality between the front end and the back end and among various services and among languages, quickly provides the service protocol which cannot be quickly exposed originally to the front end and the service party calling party, and effectively solves the calling problem among multiple languages.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a protocol conversion method based on an http micro-service gateway is characterized by comprising the following steps:
a, a micro service gateway acquires and caches registered dubbo metadata information;
b, after receiving the http protocol request in the json format, the micro service gateway finds corresponding dubbo metadata information according to parameter information in the http protocol request;
step C, the micro service gateway analyzes json object information to byte buffer binary stream of session 2 protocol of java basic data type according to found dubbo metadata information and json object in http protocol request;
step D, the micro service gateway acquires provider registered by the registration information, and analyzes the received byte buffer binary stream information of the session 2 protocol into character strings in json format;
and E, returning the character string in the json format of the http protocol by the micro service gateway.
In a preferable mode, in step a, the dubbo metadata information includes data storage information of provider of the dubbo service and basic K/V of a provider.
Preferably, the data storage information of the basic K/V of the consumer includes the interface address information of the request, the request type, the dubbo version, the version, and the return object information.
Based on the same inventive concept, the invention also provides a protocol conversion device based on the http micro service gateway, which is characterized in that the micro service gateway is configured to execute the steps of the protocol conversion method.
Compared with the prior art, the method and the device have the advantages that the registered dubbo metadata information is acquired from the metadata center, the mapping relation between the json object and the metadata is analyzed in a stepwise analysis mode, the final session 2 serialized buffer is assembled, the corresponding provider is requested, the received session 2 serialized byte buffer is analyzed into a json character string, and the character string returned to the json format is finally output. The invention can effectively improve the calling universality between the front end and the back end and among various services and among languages, quickly provides the service protocol which cannot be quickly exposed originally to the front end and the service party calling party, and effectively solves the calling problem among multiple languages.
Drawings
Fig. 1 is a schematic diagram of a conventional micro-service gateway-based protocol for converting a dubbo protocol into an http protocol.
Fig. 2 is a schematic diagram illustrating the principle of the http microservice gateway-based protocol conversion method of the present invention.
Detailed Description
As shown in fig. 2, the protocol conversion method based on the http microservice gateway includes the following steps:
a, a micro service gateway acquires and caches registered dubbo metadata information; the dubbo metadata information comprises provider of the dubbo service and data storage information of basic K/V of a provider. The data storage information of the basic K/V of the consumer comprises the interface address information of the request, the request type, the dubbo version, the return object information and the like.
And step B, the microservice gateway receives the http protocol request in the json format. The request body comprises interface information, version information and a json character string of the request. And finding corresponding dubbo metadata interface information through the interface version and other related information in the http protocol request. Parameter information such as interface version and the like can be respectively agreed in url connection, and the json object of the dubbo request can be sent in body.
And step C, the micro service gateway performs protocol conversion according to the found dubbo metadata information and the json object in the http protocol request, and analyzes the json object information to byte buffer binary stream of the session 2 protocol of the java basic data type. And traversing and reading the whole json character string, acquiring the type of each read json fragment through metadata, and writing the json fragment into the buffer in detail by using the session 2 protocol. And requesting a corresponding remote service from a byte buffer of the session 2 protocol, converting the remote service into a corresponding javabean, requesting a corresponding method, returning the corresponding javabean, converting the javabean into a byte buffer, and sending the byte buffer to the micro service gateway.
Step D, the micro service gateway acquires provider registered by the registration information, and analyzes the received byte buffer binary stream information of the session 2 protocol into character strings in json format;
and E, returning the character string in the json format by the micro service gateway through the http protocol.
The invention also provides a protocol conversion device based on the http micro service gateway, wherein the micro service gateway is configured to execute the steps of the protocol conversion method.
The core function of the invention is to convert the dubbo protocol to the http protocol in json format. The protocol conversion of the http micro-service gateway is based on the universality of java service, a json format request is converted into a dubbo protocol of a java basic data type by depending on metadata, dubbo service calling is carried out, returned dubbo protocol information is returned to a json format protocol, a json format http protocol request → dubbo protocol back-end service → dubbo protocol return data → json file is formed through the http micro-service gateway, and a front-end and service-related friendly calling chain is formed.
The invention is applied to the project of 'audio-visual media microservice key technology research and application' (the project number is 2019YFB1405900), and specifically comprises the following steps:
1. defining the parameters related to the general micro service request information and the json object of body and request. The main parameters are as follows: interface information, method, version, and group.
2. And the micro service gateway receives the http request and finds corresponding metadata information according to the parameter information.
3. And the micro service gateway analyzes the json object information to byte buffer binary stream of the session 2 protocol of java basic data type according to the found metadata information and the json object of the request.
4. The micro service gateway takes the provider registered by the registration information, and the load balancing request is sent to a specific example.
5. The micro service gateway correspondingly analyzes the binary stream information of the byte buffer returned by the provider to a basic type according to the method of the metadata, and then to a json object.
6. And finally returning the json format character string of the http protocol by the microservice gateway.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (4)

1. A protocol conversion method based on an http micro-service gateway is characterized by comprising the following steps:
a, a micro service gateway acquires and caches registered dubbo metadata information;
b, after receiving the http protocol request in the json format, the micro service gateway finds corresponding dubbo metadata information according to parameter information in the http protocol request;
step C, the micro service gateway carries out protocol conversion according to the found dubbo metadata information and the json object in the http protocol request, and analyzes the json object information to byte buffer binary stream of the session 2 protocol of the java basic data type; traversing and reading the whole json character string, acquiring the type of each read json fragment through metadata, writing the json fragment into a buffer in detail by using a session 2 protocol, requesting a corresponding remote service by using a byte buffer of the session 2 protocol, converting the remote service into a corresponding javabean, requesting a corresponding method, returning the corresponding javabean, and converting the javabean into the byte buffer to be sent to a micro-service gateway;
step D, the micro service gateway acquires provider registered by the registration information, and analyzes the received byte buffer binary stream information of the session 2 protocol into character strings in json format;
and E, the microservice gateway returns the character string of the json format of the http protocol.
2. The http micro-service gateway based protocol conversion method as claimed in claim 1, wherein in the step a, the dubbo metadata information includes data storage information of provider of the dubbo service and basic K/V of a provider.
3. The http microservices gateway based protocol conversion method of claim 2, wherein the consumer base K/V data storage information includes requested interface address information, request type, dubbo version, return object information.
4. A protocol conversion device based on an http microservice gateway, characterized in that the microservice gateway is configured for performing the steps of the method according to one of claims 1 to 3.
CN202110472605.0A 2021-04-29 2021-04-29 Protocol conversion method and protocol conversion device based on http micro-service gateway Active CN113242221B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110472605.0A CN113242221B (en) 2021-04-29 2021-04-29 Protocol conversion method and protocol conversion device based on http micro-service gateway

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110472605.0A CN113242221B (en) 2021-04-29 2021-04-29 Protocol conversion method and protocol conversion device based on http micro-service gateway

Publications (2)

Publication Number Publication Date
CN113242221A CN113242221A (en) 2021-08-10
CN113242221B true CN113242221B (en) 2022-08-23

Family

ID=77131472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110472605.0A Active CN113242221B (en) 2021-04-29 2021-04-29 Protocol conversion method and protocol conversion device based on http micro-service gateway

Country Status (1)

Country Link
CN (1) CN113242221B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113726869A (en) * 2021-08-26 2021-11-30 阿里巴巴(中国)有限公司 Communication method, gateway and electronic equipment
CN114205191B (en) * 2021-12-13 2023-09-15 四川启睿克科技有限公司 API gateway system and operation method
CN114942856B (en) * 2022-07-22 2022-11-04 浙江中控技术股份有限公司 Data processing method and device of micro-service system and electronic equipment
CN115604333B (en) * 2022-10-12 2023-09-12 江苏赛融科技股份有限公司 Distributed big data analysis service scheduling method and system based on dubbo
CN116192933B (en) * 2022-12-12 2023-09-19 北京领雁科技股份有限公司 Method and system for dynamically expanding non-HTTP protocol based on micro-service gateway

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108255615B (en) * 2017-11-30 2022-03-01 平安科技(深圳)有限公司 Cross-language calling method, server and storage medium
US10503726B2 (en) * 2017-12-21 2019-12-10 Adobe Inc. Reducing frontend complexity for multiple microservices with consistent updates
CN110780950B (en) * 2019-10-24 2024-02-20 深圳前海环融联易信息科技服务有限公司 Interface metadata management method, device, computer equipment and storage medium
CN110990047B (en) * 2019-11-06 2021-11-19 北京云思畅想科技有限公司 Fusion method and device for multiple microservice architectures
CN112256246A (en) * 2020-09-18 2021-01-22 许继集团有限公司 Micro-service integration framework for supporting cross-language calling in power system
CN112685193B (en) * 2020-12-18 2024-03-22 易久批信息技术有限公司 Micro-service gateway interface exposing and aggregating method

Also Published As

Publication number Publication date
CN113242221A (en) 2021-08-10

Similar Documents

Publication Publication Date Title
CN113242221B (en) Protocol conversion method and protocol conversion device based on http micro-service gateway
US8069451B2 (en) System and method of compact messaging in network communications by removing tags and utilizing predefined message definitions
US6779154B1 (en) Arrangement for reversibly converting extensible markup language documents to hypertext markup language documents
CN108989356A (en) A kind of method that API gateway realizes protocol conversion
US8626951B2 (en) Interoperability of network applications in a communications environment
CN100392650C (en) Enhancement of database performance in a domain name system
US20050188111A1 (en) Method and system for creating pervasive computing environments
US20090150905A1 (en) Integrating non-xml protocols into web browsing applications
CN112511591B (en) Method, device, equipment and medium for realizing hospital interface data interaction
CN101257538B (en) Method and apparatus for processing request in browsers
CN101882293A (en) Method and system for processing data between domestic custodian bank and overseas custodian agent bank
CN101500145A (en) Digital household public transportation enquiry system based on bi-directional set-top box
CN111431746A (en) API gateway migration method and system
US20170085646A1 (en) Method and apparatus for processing media type in rest software architecture
CN103002047B (en) A kind of RPC formulas web server architecture method
CN107241422B (en) Method for synchronizing external user and user group information into Apache Range in real time
CN101039320A (en) Method and apparatus for providing an interface between a client application and a web service
CN103020062A (en) Front end and server interaction realization method based on XML-RPC (Extensive Makeup Language-Remote Procedure Calling)
CN109005163B (en) HTTP dynamic request service calling method
CN102946423A (en) Data mapping and pushing system and method based on distributed system architecture
CN105224319A (en) The method of XBRL instance document preview is realized based on dom4j
US8185911B2 (en) System and method for simplification of data structure in wireless communications
CN112433870A (en) Data calling method and device, computer readable storage medium and electronic equipment
CN112217915B (en) Cloud adaptation transformation method and device for traditional environment internet access area
KR20010069793A (en) Method for providing interactive voice response(IVR) service by converting wireless application protocol(WAP)-based contents for wireless internet into voice extensible markup language(VXML)-based contents and system therefor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant