CN112688977B - Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium - Google Patents

Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium Download PDF

Info

Publication number
CN112688977B
CN112688977B CN201910990170.1A CN201910990170A CN112688977B CN 112688977 B CN112688977 B CN 112688977B CN 201910990170 A CN201910990170 A CN 201910990170A CN 112688977 B CN112688977 B CN 112688977B
Authority
CN
China
Prior art keywords
micro
service
service system
proxy
micro service
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
CN201910990170.1A
Other languages
Chinese (zh)
Other versions
CN112688977A (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.)
Zhejiang Dasou Vehicle Software Technology Co Ltd
Original Assignee
Zhejiang Dasou Vehicle Software Technology 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 Zhejiang Dasou Vehicle Software Technology Co Ltd filed Critical Zhejiang Dasou Vehicle Software Technology Co Ltd
Priority to CN201910990170.1A priority Critical patent/CN112688977B/en
Publication of CN112688977A publication Critical patent/CN112688977A/en
Application granted granted Critical
Publication of CN112688977B publication Critical patent/CN112688977B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The micro-service communication method is applied to a cross-network deployed micro-service system, and the micro-service system at least comprises a first micro-service system and a second micro-service system; the method comprises the steps that a first micro-service system receives a call request sent by a micro-service consumer in the first micro-service system through an onboard proxy service; wherein the proxy service subscribes to a micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system; responding to the call request, and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service; and forwarding the calling response to the micro-service consumer in the first micro-service system so as to complete micro-service communication between micro-service systems deployed across networks, thereby avoiding repeated deployment of the micro-service systems and improving the development and operation efficiency of the user based on the micro-service.

Description

Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium
Technical Field
The present disclosure relates to the field of computer applications, and in particular, to a micro-service communication method, apparatus, electronic device, and machine-readable storage medium.
Background
Under the background of the traditional IT technology, a business system of a company is usually formed by stacking a plurality of software subsystems with independent business, and along with the development and change of the business of the company, the business system is more complex, so that the problems of high maintenance cost, poor scalability and the like of the business system are caused. With the continuous development and progress of the IT industry, the development of the service system based on the micro-service architecture can effectively solve the above problems.
The micro-service architecture is an emerging architecture technology for developing and deploying business systems based on cloud computing technology, thereby providing users with sub-divided business services. In practical application, a micro service system can be constructed based on the micro service architecture, so that a plurality of service modules with independent functions can be respectively packaged and exposed to a user in a service interface mode, and the user can construct the service system based on the micro service provided by the micro service system.
Disclosure of Invention
The application provides a micro-service communication method, which is applied to a cross-network deployed micro-service system; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the method comprises the following steps:
The method comprises the steps that a first micro-service system receives a call request sent by a micro-service consumer in the first micro-service system through an onboard proxy service; wherein the proxy service subscribes to a micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
responding to the call request, and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service;
and forwarding the calling response to a micro-service consumer in the first micro-service system so as to complete micro-service communication between micro-service systems deployed across networks.
Optionally, before the proxy service receives the transmitted call request from the micro service consumer in the first micro service system, the method further includes:
and coordinating service through the application program carried by the second micro service system, wherein the proxy service subscribes to the micro service of the second micro service system.
Optionally, the coordination service of the application program carried by the second micro service system, the proxy service subscribes to the micro service of the second micro service system, including:
Coordinating a service by an application program carried by the second micro service system, wherein the proxy service is registered as a micro service consumer of the second micro service system;
the proxy service obtains published micro services in the second micro service system from micro service providers in the second micro service system.
Optionally, the method further comprises:
coordinating a service by an application program carried by the first micro service system, wherein the proxy service is registered as a micro service provider of the first micro service system;
and publishing the service interface corresponding to the published micro service in the second micro service system in the first micro service system so as to enable the consumer in the first micro service system to acquire the service interface.
Optionally, the application program carried by the second micro service system coordinates a service, and the proxy service is registered as a micro service consumer of the second micro service system, including:
the proxy service and the second micro service system establish a network long connection which passes through the first intranet and the second intranet and is used for safety communication through the application program coordination service carried by the second micro service system;
Based on the network long connection, the proxy service registers as a micro-service consumer of the second micro-service system.
Optionally, the micro service system is a distributed system based on a Dubbo framework for providing RPC services.
Optionally, the application coordination service is a ZooKeeper service.
The application also provides a micro-service communication device which is applied to a cross-network deployed micro-service system; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the device comprises:
the receiving module is used for receiving a call request sent by a micro service consumer in the first micro service system through the carried proxy service; wherein the proxy service subscribes to a micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
The acquisition module is used for responding to the call request and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service;
and the forwarding module forwards the calling response to the micro service consumer in the first micro service system so as to complete micro service communication between the micro service systems deployed across networks.
Optionally, before the proxy service receives the transmitted call request from the micro service consumer in the first micro service system, the method further includes:
and the subscription and release module coordinates the service through the application program carried by the second micro service system, and the proxy service subscribes the micro service of the second micro service system.
Optionally, the subscription publishing module further:
coordinating a service by an application program carried by the second micro service system, wherein the proxy service is registered as a micro service consumer of the second micro service system;
the proxy service obtains published micro services in the second micro service system from micro service providers in the second micro service system.
Optionally, the subscription publishing module further:
coordinating a service by an application program carried by the first micro service system, wherein the proxy service is registered as a micro service provider of the first micro service system;
And publishing the service interface corresponding to the published micro service in the second micro service system in the first micro service system so as to enable the consumer in the first micro service system to acquire the service interface.
Optionally, the subscription publishing module further:
the proxy service and the second micro service system establish a network long connection which passes through the first intranet and the second intranet and is used for safety communication through the application program coordination service carried by the second micro service system;
based on the network long connection, the proxy service registers as a micro-service consumer of the second micro-service system.
Optionally, the micro service system is a distributed system based on a Dubbo framework for providing RPC services.
Optionally, the application coordination service is a ZooKeeper service.
The application also provides electronic equipment, which comprises a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are connected with each other through the bus;
the memory stores machine readable instructions and the processor performs the method described above by invoking the machine readable instructions.
The present application also provides a machine-readable storage medium storing machine-readable instructions that, when invoked and executed by a processor, implement the above-described methods.
With the above embodiment, the proxy service is carried based on the first micro service system in the micro service systems deployed across networks; and the proxy service proxies call requests of service consumers in the first micro service system to the micro service in the second micro service system, call responses corresponding to the call requests are obtained from the second micro service system, and the call responses are forwarded to the corresponding service consumers in the first micro service system, so that micro service communication among a plurality of micro service systems deployed across networks is realized, the provided micro service of different micro service systems is fully utilized, repeated deployment of the micro service systems is avoided, and development and operation efficiency of users based on micro service is improved.
Drawings
FIG. 1 is a networking diagram of a microservice system provided by an exemplary embodiment;
FIG. 2 is a networking diagram of a plurality of micro-service systems deployed across a network, provided by an exemplary embodiment;
FIG. 3 is a flow chart of a method of microservice communication provided by an exemplary embodiment;
FIG. 4 is a networking diagram of a plurality of microservice systems deployed across a network in accordance with another exemplary embodiment;
FIG. 5 is a hardware configuration diagram of an electronic device according to an exemplary embodiment;
fig. 6 is a block diagram of a micro-service communication device provided by an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first message may also be referred to as a second message, and similarly, a second message may also be referred to as a first message, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present specification, the following briefly describes the related art of micro service communication related to the embodiments of the present specification.
Referring to fig. 1, fig. 1 is a networking diagram of a micro service system according to an embodiment of the present disclosure.
The micro service system as shown in fig. 1 includes: an application coordination service P, C; wherein P represents a micro service provider in the micro service system, and C represents a micro service consumer in the micro service system; both the micro service provider and the micro service consumer conduct management maintenance through the application coordination service.
As shown in fig. 1, the coordination completion information interaction between the micro service provider P and the micro service consumer C through the application coordination service mainly includes 3 steps: 1. declaring a service; 2. discovering a service; 3. calling a service;
the declaration service refers to a service interface which can be provided by the micro service provider P through the coordination service of an application program; step 2, discovering the service refers to the micro service consumer C discovering the declared service interface of the micro service provider P through the coordination service of the application program; step 3, calling the service refers to that the micro service consumer C calls the service interface declared by the micro service provider P, and after the micro service provider P executes the micro service processing corresponding to the service interface, a calling response corresponding to the service interface is returned to the micro service consumer C.
It should be noted that, for the detailed interaction process of the micro service system shown in fig. 1, please refer to the description of the micro service system technology, and the detailed description is omitted herein.
Referring to fig. 2, fig. 2 is a networking diagram of a plurality of micro service systems deployed across a network according to an embodiment of the present disclosure.
The networking as shown in fig. 2 includes: systemA, systemB; the system A and the system B are micro-service systems which are deployed and isolated from different intranets (intranet A and intranet B) respectively; the networking architecture of the single micro service system indicated by systemu and systemu is the same as that of the micro service system shown in fig. 1, and is not described here again, but only the naming of the micro service consumer, the micro service provider, and the application coordination service is different.
As shown in fig. 2, the micro service system SystemA includes: application coordination services A, P, C1; wherein P1 represents a micro service provider in the micro service system, and C1 represents a micro service consumer in the micro service system; both the micro service provider and the micro service consumer perform management maintenance through the application coordination service a.
As shown in fig. 2, the micro service system SystemB includes: application coordination services B, P, C2; wherein P2 represents a micro service provider in the micro service system, and C2 represents a micro service consumer in the micro service system; both the micro service provider and the micro service consumer perform management maintenance through the application coordination service B.
Based on the networking architecture shown above, the present specification aims to propose a technical solution for performing micro-service communication between micro-service systems deployed across networks.
When the method is realized, the cross-network deployed micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first intranet and the second intranet are isolated by the intranet, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management.
Further, the first micro service system receives a call request sent by a micro service consumer in the first micro service system through the carried proxy service; wherein the proxy service subscribes to the micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
further, in response to the call request, acquiring a call response corresponding to the call request from the second micro-service system by the proxy service; and forwarding the calling response to the micro service consumer in the first micro service system to complete micro service communication between the micro service systems deployed across the network.
In the above technical solution, proxy services are carried on the basis of a first micro service system in the micro service systems deployed across networks; and the proxy service proxies the call request of the service consumer in the first micro service system to the micro service in the second micro service system, obtains the call response corresponding to the call request from the second micro service system, and forwards the call response to the service consumer in the corresponding first micro service system, thereby realizing micro service communication among a plurality of micro service systems deployed across networks, fully utilizing the micro service provided by the existing different micro service systems, avoiding repeated deployment of the micro service systems, and improving the development and operation efficiency of users based on the micro service.
The following description is made by specific embodiments and with reference to specific application scenarios.
Referring to fig. 3, fig. 3 is a flowchart of a micro service communication method provided in an embodiment of the present disclosure, where the method is applied to a micro service system deployed across networks, and the micro service system at least includes a first micro service system deployed in a first intranet and a second micro service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the method performs the following steps:
step 302, the first micro service system receives a call request sent by a micro service consumer in the first micro service system through the carried proxy service; wherein the proxy service subscribes to the micro service provided by the second micro service system; the call request includes at least a service interface corresponding to the micro-service provided by the second micro-service system.
And step 304, responding to the call request, and acquiring a call response corresponding to the call request from the second micro service system by the proxy service.
Step 306, forwarding the call response to the micro service consumer in the first micro service system to complete the micro service communication between the micro service systems deployed across the network.
For ease of understanding, the composition of the microservice system and related concepts are reiterated herein.
The micro service system mainly comprises an application program coordination service, a micro service provider and a micro service consumer; wherein, the micro service provider and the micro service consumer both coordinate the service to manage and maintain through the application program. The micro service consumer may invoke the micro service provided by the micro service provider through the application coordination service, and the detailed process is described in detail in the foregoing description of the micro service system shown in fig. 1, which is not repeated here.
In the present specification, the application coordination service refers to distributed management software for performing micro-service management in a single micro-service system.
In one embodiment shown, the application coordination service may be a ZooKeeper service.
For example, referring to fig. 1, the application coordination service may be a ZooKeeper service; for a specific description of the ZooKeeper service, please refer to the ZooKeeper technical description, and the description is omitted here.
Of course, in practical applications, the application coordination service may be other services, for example, the application coordination service may also be a Nacos service or a Redis service, and specific please refer to technical descriptions of the Nacos service and the Redis service, which are not described herein.
In the present specification, the first micro service system refers to a micro service system deployed in a first intranet; the first intranet refers to a network environment where the first micro-service system is deployed correspondingly.
For example, referring to fig. 2, the first micro service system may be a micro service system a deployed in the intranet a or a micro service system B deployed in the intranet B.
In the present specification, the second micro service system refers to a micro service system deployed in a second intranet; the second intranet refers to a network environment where the second micro service system is deployed correspondingly.
For example, referring to fig. 2, the second micro service system may be a micro service system B deployed in the intranet B, or may be a micro service system a deployed in the intranet a.
The first intranet corresponding to the first micro-service system and the second intranet corresponding to the second micro-service system are intranet-isolated.
For example, referring to fig. 2, intranet isolation is performed between the intranet a and the intranet B corresponding to the micro service system a and the micro service system B, that is, members in the micro service system a and members in the micro service system B cannot directly perform micro service communication.
In the present specification, the micro service system refers to a plurality of micro service systems deployed in different intranets and isolated from the intranets;
wherein the micro-service system at least comprises the first micro-service system and the second micro-service system; the first micro service system and the second micro service system are respectively provided with the application coordination service for micro service management.
For example, referring to fig. 2, the micro service system includes a micro service system a and a micro service system b; the micro-service system A and the micro-service system B are correspondingly deployed intranet A and intranet B which are isolated by the intranet; the micro service system A and the micro service system B are respectively provided with an application coordination service A and an application coordination service B for micro service management.
In one embodiment shown, the micro-service system described above is a Dubbo framework-based distributed system that provides RPC (Remote Procedure Call ) services; for a detailed description of the Dubbo framework and the RPC service, please refer to the related art description, and the detailed description is omitted here.
Of course, the micro service system may also be a distributed system that provides other micro services, and the type of micro service provided by the micro service system is not particularly limited in the present specification.
Referring to fig. 4, fig. 4 is a networking diagram of a plurality of micro service systems deployed across a network according to another embodiment of the present disclosure.
The specific components of the networking architecture of the micro service system shown in fig. 4 are the same as the detailed description of fig. 2, and are not repeated here.
Fig. 4 is a variation on fig. 2, fig. 4 being substantially identical to fig. 2, except that fig. 4 has an increase in A1 from fig. 2; wherein A1 is both a micro service provider in micro service system System A and a micro service consumer in micro service system System B.
As shown in steps S1 to S6 of fig. 4, it is shown that A1 is a micro service consumer C1 in the micro service system a, and a communication procedure for calling the micro service of the micro service provider C1 in the micro service system b is provided.
For ease of understanding, the overall flow of the micro service communication shown in fig. 4 is briefly described here, and mainly includes 6 steps S1 to S6;
the step S1 of declaring services refers to that a micro service provider P2 in a micro service system B declares a service interface which can be provided by the micro service provider P2 through an application coordination service B; s2, discovering service refers to that A1 discovers a service interface declared by a micro service provider P2 through an application coordination service B; s3, declaring services refers to that A1 declares a service interface which can be provided by the A through an application program coordination service; s4, discovering the service refers to the fact that the micro service consumer C1 discovers the service interface declared by the A1 through the application program coordination service A; s5, calling the service means that the micro-service consumer C1 calls the service interface stated by the A1, so that micro-service calling is completed; step S6, calling the service refers to calling the micro service of the micro service consumer C1, correspondingly, the A1 calls the service interface which is declared by the P2, so that the corresponding micro service call is executed, and after the micro service provider P2 executes the micro service processing corresponding to the service interface, a call response corresponding to the service interface is returned to the micro service consumer C1 through the A1.
For convenience of description and understanding, the following description will be given by way of example with the first micro service system being the micro service system a shown in fig. 4, and the second micro service system being the micro service system b shown in fig. 4.
In the present specification, the proxy service refers to a service component for performing cross-network micro-service communication, which is mounted on each of the micro-service systems.
For example, in practical applications, the proxy service may be a micro service provider in the second micro service system in the micro service system; and as a micro service consumer in the first one of the micro service systems.
For another example, in practical applications, the proxy service may be a micro service provider in the first micro service system of the micro service systems; and as a micro service consumer in the second one of the micro service systems.
For convenience of understanding and description, the proxy service is subsequently used as a micro service provider in the first micro service system in the micro service system; and, as a micro service consumer in the second micro service system in the micro service system, an example description is made.
In the present specification, the first micro service system receives a call request transmitted from a micro service consumer in the first micro service system through the proxy service installed in the first micro service system; wherein the proxy service subscribes to a micro service provided by the second micro service system; the call request at least includes a service interface corresponding to a micro service provided by the second micro service system.
For example, as shown in fig. 4, the proxy service is a proxy service A1 installed in a micro service system a; wherein the proxy service A1 subscribes to the micro service provided by the micro service provider P2 in the micro service system systemeb. The proxy service A1 receives a call request sent by a micro service consumer C1 in the micro service system A; the call request at least includes service interfaces corresponding to the micro services provided by the second micro service system (for example, various interfaces of the RPC service, please refer to the RPC technical description, and the description is omitted here).
In one embodiment, the proxy service subscribes to the micro service of the second micro service system by an application coordination service installed in the second micro service system before the proxy service receives the call request sent from the micro service consumer in the first micro service system.
Continuing with the above example, as shown in fig. 4, before the proxy service A1 receives the call request sent from the micro service consumer C1 of the micro service system a, the proxy service A1 subscribes to the micro service provided by the micro service provider P2 of the micro service system B corresponding to the call request through the application coordination service B carried by the micro service system B.
In one embodiment, in the process of the proxy service subscribing to the micro service of the second micro service system, the proxy service is registered as a micro service consumer of the second micro service system by the application coordination service carried by the second micro service system.
Continuing with the above example, referring to step S1 shown in fig. 4, in the process that the proxy service A1 subscribes to the micro service of the micro service system B through the application coordination service B carried by the micro service system B, the proxy service A1 is registered as the micro service consumer of the micro service system B through the application coordination service B carried by the micro service system B.
In one embodiment, in the process of registering the application coordination service carried by the second micro service system as the micro service consumer of the second micro service system, the proxy service establishes a network length connection for secure communication with the second micro service system, the network length connection crossing the first intranet and the second intranet.
Continuing to exemplify the above example, please refer to step S2 shown in fig. 4, in the process that the proxy service A1 is registered as a micro service consumer of the micro service system B through the application coordination service B carried by the micro service system B, the proxy service A1 and the micro service system B establish a network long connection for secure communication traversing the intranet a and the intranet B through the application coordination service B carried by the micro service system B; before the network long connection is established, a specific IP address, a port, etc. for performing long connection communication between the proxy service A1 and the micro service system b may be set based on a preset user configuration.
The network long connection is a TCP long connection based on RPC service; for specific concepts and technical principles of the TCP long connection, please refer to the technical description of the TCP long connection, and the detailed description is omitted herein.
In the present specification, further, the proxy service is registered as a micro service consumer of the second micro service system based on the network long connection.
Continuing with the above example, please refer to step S2 of fig. 4, the proxy service A1 is a micro service consumer of the micro service system systemeb based on the long network connection.
In this specification, after the proxy service is registered as a micro service consumer of the second micro service system, the proxy service may call a micro service provided by a micro service provider in the second micro service system.
Continuing with the above example, referring to steps S2 through S6 shown in fig. 4, after the proxy service A1 is a micro service consumer of the micro service system b, the proxy service A1 may invoke the micro service provided by the micro service provider P2 in the micro service system b.
Of course, in practical applications, the proxy service may also be based on related tools of JAVA technology (for example, may include JAVA service byte toolkit), and by acquiring an interface class corresponding to the micro service provided by the micro service system b and an implementation class corresponding to the interface class, a service interface corresponding to the micro service in the micro service system b is caused to the micro service system a at one time, and please refer to the related tools of JAVA technology for details, which are not described herein again.
In one embodiment, after the proxy service subscribes to the micro service of the second micro service system, the proxy service is registered as a micro service provider of the first micro service system by an application coordination service installed in the first micro service system.
Continuing with the above example, please refer to steps S1 to S3 shown in fig. 4, after the proxy service A1 subscribes to the micro service of the micro service system b, the service a is coordinated by the application program carried by the micro service system a, and the proxy service is registered as the micro service provider of the micro service system a.
In this specification, further, the proxy service publishes a service interface corresponding to the published micro service in the second micro service system in the first micro service system, so as to enable the consumer in the first micro service system to obtain the service interface.
Continuing with the above example, please refer to step S4 shown in fig. 4, further, the proxy service A1 publishes the service interface corresponding to the published micro service of P2 in the micro service system b in the micro service system a, so as to enable the consumer C1 in the micro service system a to obtain.
In the present specification, after receiving the call request, the proxy service obtains a call response corresponding to the call request from the second micro service system in response to the call request.
Continuing the above example, please refer to steps S5 to S6 shown in fig. 4, after receiving a call request of the service interface corresponding to the P2 micro service to be called by the C1, continuing to call the micro service provided by the P2 corresponding to the call request from the micro service system b by the proxy service A1; and acquiring a call response corresponding to the micro service provided by the P2.
In this specification, further, the proxy service forwards the call response to the micro service consumer in the first micro service system to complete the micro service communication between the micro service systems deployed across the network.
Continuing with the above example, proxy service A1 forwards the call response provided by P2 in micro service system b and corresponding to the call request to C1 in micro service system a, so as to complete micro service communication between micro service systems deployed across networks.
In the above technical solution, proxy services are carried on the basis of a first micro service system in the micro service systems deployed across networks; and the proxy service proxies the call request of the service consumer in the first micro service system to the micro service in the second micro service system, obtains the call response corresponding to the call request from the second micro service system, and forwards the call response to the service consumer in the corresponding first micro service system, thereby realizing micro service communication among a plurality of micro service systems deployed across networks, fully utilizing the micro service provided by the existing different micro service systems, avoiding repeated deployment of the micro service systems, and improving the development and operation efficiency of users based on the micro service.
Corresponding to the above method embodiments, embodiments of the micro-service communication device are also provided.
Corresponding to the above method embodiments, the present specification also provides an embodiment of a micro-service communication device. Embodiments of the micro service communication apparatus of the present description may be applied to an electronic device. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. Taking software implementation as an example, the device in a logic sense is formed by reading corresponding computer program instructions in a nonvolatile memory into a memory by a processor of an electronic device where the device is located for operation. In terms of hardware, as shown in fig. 5, a hardware structure diagram of an electronic device where the micro service communication device apparatus of the present disclosure is located is shown in fig. 5, and in addition to the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 5, the electronic device where the apparatus is located in the embodiment generally may further include other hardware according to the actual function of the electronic device, which is not described herein again.
Fig. 6 is a block diagram of a micro-service communication device according to an exemplary embodiment of the present description.
Referring to fig. 6, the micro service communication apparatus 60 may be applied to the electronic device shown in fig. 5, which is applied to a micro service system deployed across networks; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the device comprises:
The receiving module 601, the first micro service system receives a call request sent by a micro service consumer in the first micro service system through the carried proxy service; wherein the proxy service subscribes to the micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
the obtaining module 602 is used for obtaining a call response corresponding to the call request from the second micro service system by the proxy service in response to the call request;
the forwarding module 603 forwards the call response to the micro service consumer in the first micro service system to complete the micro service communication between the micro service systems deployed across the network.
In this embodiment, before the proxy service receives the transmitted call request from the micro service consumer in the first micro service system, it further includes:
the subscription publishing module 604 coordinates services through the application program carried by the second micro service system, and the proxy service subscribes to the micro service of the second micro service system.
In this embodiment, the subscription publishing module 604 further:
the agent service is registered as a micro-service consumer of the second micro-service system through the application program coordination service carried by the second micro-service system;
The proxy service obtains the published micro services in the second micro service system from the micro service provider in the second micro service system.
In this embodiment, the subscription publishing module 604 further:
the method comprises the steps that through an application program coordination service carried by a first micro-service system, proxy service is registered as a micro-service provider of the first micro-service system;
and publishing the service interface corresponding to the published micro service in the second micro service system in the first micro service system so as to enable the consumer in the first micro service system to acquire the service interface.
In this embodiment, the subscription publishing module 604 further:
the proxy service and the second micro-service system establish a network long connection which passes through the first intranet and the second intranet and is used for safety communication through the application program coordination service carried by the second micro-service system;
based on the network long connection, the proxy service registers as a micro service consumer of the second micro service system.
In this embodiment, the micro service system is a distributed system based on the Dubbo framework that provides RPC services.
In this embodiment, the application coordination service is a ZooKeeper service.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, in which the modules illustrated as separate components may or may not be physically separate, and the components shown as modules may or may not be physical, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present application. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The apparatus, device, module or module set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
Corresponding to the method embodiment described above, the present specification also provides an embodiment of an electronic device. The electronic equipment can be applied to a micro-service system deployed across networks; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the electronic device includes: a processor and a memory for storing machine executable instructions; wherein the processor and the memory are typically interconnected by an internal bus. In other possible implementations, the device may also include an external interface to enable communication with other devices or components.
In this embodiment, the processor is caused to, by reading and executing the stored machine-executable instructions corresponding to the control logic of the microservice communication:
the first micro service system receives a call request sent by a micro service consumer in the first micro service system through the carried proxy service; wherein the proxy service subscribes to the micro service provided by the second micro service system; the call request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
responding to the call request, and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service;
and forwarding the calling response to the micro service consumer in the first micro service system to complete micro service communication between the micro service systems deployed across the network.
In this embodiment, the processor is caused to, prior to the proxy service receiving a transmitted call request from a micro service consumer in the first micro service system, by reading and executing the stored machine executable instructions corresponding to the control logic of the micro service communication stored in the memory:
the proxy service subscribes to the micro services of the second micro service system through the application coordination service carried by the second micro service system.
In this embodiment, the processor is caused to, by reading and executing the stored machine-executable instructions corresponding to the control logic of the microservice communication:
the agent service is registered as a micro-service consumer of the second micro-service system through the application program coordination service carried by the second micro-service system;
the proxy service obtains the published micro services in the second micro service system from the micro service provider in the second micro service system.
In this embodiment, the processor is caused to, by reading and executing the stored machine-executable instructions corresponding to the control logic of the microservice communication:
the method comprises the steps that through an application program coordination service carried by a first micro-service system, proxy service is registered as a micro-service provider of the first micro-service system;
and publishing the service interface corresponding to the published micro service in the second micro service system in the first micro service system so as to enable the consumer in the first micro service system to acquire the service interface.
In this embodiment, the processor is caused to, by reading and executing the stored machine-executable instructions corresponding to the control logic of the microservice communication:
the proxy service and the second micro-service system establish a network long connection which passes through the first intranet and the second intranet and is used for safety communication through the application program coordination service carried by the second micro-service system;
Based on the network long connection, the proxy service registers as a micro service consumer of the second micro service system.
In this embodiment, the micro service system is a distributed system based on the Dubbo framework that provides RPC services.
In this embodiment, the application coordination service is a ZooKeeper service.
Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It is to be understood that the present description is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The foregoing description of the preferred embodiments is provided for the purpose of illustration only, and is not intended to limit the scope of the disclosure, since any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the disclosure are intended to be included within the scope of the disclosure.

Claims (9)

1. A micro-service communication method, the method is applied to a micro-service system deployed across networks; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the method comprises the following steps:
the proxy service subscribes to the micro service of the second micro service system through the coordination service of the application program carried by the second micro service system;
the method comprises the steps that a first micro-service system receives a call request sent by a micro-service consumer in the first micro-service system through an onboard proxy service; wherein the call request at least comprises a service interface corresponding to a micro service provided by the second micro service system;
responding to the call request, and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service;
and forwarding the calling response to a micro-service consumer in the first micro-service system so as to complete micro-service communication between micro-service systems deployed across networks.
2. The method of claim 1, the application coordination service hosted by the second micro service system, the proxy service subscribing to the micro service of the second micro service system, comprising:
coordinating a service by an application program carried by the second micro service system, wherein the proxy service is registered as a micro service consumer of the second micro service system;
the proxy service obtains published micro services in the second micro service system from micro service providers in the second micro service system.
3. The method of claim 2, further comprising:
coordinating a service by an application program carried by the first micro service system, wherein the proxy service is registered as a micro service provider of the first micro service system;
and publishing the service interface corresponding to the published micro service in the second micro service system in the first micro service system so as to enable the consumer in the first micro service system to acquire the service interface.
4. The method of claim 2, the application coordination service hosted by the second micro service system, the proxy service registered as a micro service consumer of the second micro service system, comprising:
The proxy service and the second micro service system establish a network long connection which passes through the first intranet and the second intranet and is used for safety communication through the application program coordination service carried by the second micro service system;
based on the network long connection, the proxy service registers as a micro-service consumer of the second micro-service system.
5. The method of claim 1, the micro-service system being a Dubbo framework-based distributed system providing RPC services.
6. The method of claim 1, the application coordination service being a ZooKeeper service.
7. A micro-service communication device, the device being applied to a micro-service system deployed across a network; the micro-service system at least comprises a first micro-service system deployed in a first intranet and a second micro-service system deployed in a second intranet; the first internal network and the second internal network are isolated by the internal network, and the first micro-service system and the second micro-service system are respectively provided with application program coordination service for micro-service management; the device comprises:
the receiving module coordinates the service through the application program carried by the second micro service system, and the proxy service subscribes to the micro service of the second micro service system; the method comprises the steps that a first micro-service system receives a call request sent by a micro-service consumer in the first micro-service system through an onboard proxy service; wherein the call request at least comprises a service interface corresponding to a micro service provided by the second micro service system;
The acquisition module is used for responding to the call request and acquiring a call response corresponding to the call request from the second micro-service system by the proxy service;
and the forwarding module forwards the calling response to the micro service consumer in the first micro service system so as to complete micro service communication between the micro service systems deployed across networks.
8. An electronic device comprises a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are connected with each other through the bus;
the memory stores machine readable instructions, the processor executing the method of any of claims 1 to 6 by invoking the machine readable instructions.
9. A machine-readable storage medium storing machine-readable instructions which, when invoked and executed by a processor, implement the method of any one of claims 1 to 6.
CN201910990170.1A 2019-10-17 2019-10-17 Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium Active CN112688977B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910990170.1A CN112688977B (en) 2019-10-17 2019-10-17 Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910990170.1A CN112688977B (en) 2019-10-17 2019-10-17 Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium

Publications (2)

Publication Number Publication Date
CN112688977A CN112688977A (en) 2021-04-20
CN112688977B true CN112688977B (en) 2023-06-16

Family

ID=75444575

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910990170.1A Active CN112688977B (en) 2019-10-17 2019-10-17 Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium

Country Status (1)

Country Link
CN (1) CN112688977B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2806557C (en) * 2010-07-26 2014-10-07 Michael Luna Mobile application traffic optimization
CN103220292B (en) * 2013-04-22 2016-08-17 广东电网公司电力科学研究院 Cross-safe-area data transmission and system
US10574736B2 (en) * 2017-01-09 2020-02-25 International Business Machines Corporation Local microservice development for remote deployment
US10523507B2 (en) * 2017-05-11 2019-12-31 Nirmata, Inc. Method and system for tuning performance of microservices-based applications
US10554675B2 (en) * 2017-12-21 2020-02-04 International Business Machines Corporation Microservice integration fabrics network intrusion detection and prevention service capabilities
CN110247944B (en) * 2018-03-09 2022-06-24 阿里巴巴集团控股有限公司 Cross-regional service calling method, device and system and electronic equipment
CN109618005B (en) * 2019-01-18 2020-12-08 华为终端有限公司 Method for calling server and proxy server
CN110225131A (en) * 2019-06-19 2019-09-10 广州小鹏汽车科技有限公司 A kind of service calling method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium

Also Published As

Publication number Publication date
CN112688977A (en) 2021-04-20

Similar Documents

Publication Publication Date Title
CN109618005B (en) Method for calling server and proxy server
CN103530255B (en) Distributed asynchronous event processing method and system
CN111163130B (en) Network service system and data transmission method thereof
WO2021088641A1 (en) Data transmission method, data processing method, data reception method and device, and storage medium
CN114189525B (en) Service request method and device and electronic equipment
CN108256069A (en) A kind of method and apparatus of the cross-domain access of the page
CN111818158B (en) Gateway control method, device, electronic equipment and storage medium
CN112214334A (en) Micro-service calling method and device, electronic equipment and computer-readable storage medium
CN106357654B (en) Remote procedure calling method, device and communication system
CN104503768A (en) Call method and device for application programming interface (API)
CN114281263B (en) Storage resource processing method, system and equipment of container cluster management system
CN112235352B (en) Service dependency carding method and device
CN112688977B (en) Micro-service communication method, micro-service communication device, electronic equipment and machine-readable storage medium
CN113254227B (en) Method and system for remote method call across data centers
CN111130978A (en) Network traffic forwarding method and device, electronic equipment and machine-readable storage medium
US11163537B1 (en) Tiered application pattern
CN111866157B (en) Cloud service gateway and cloud service internal and external request format conversion method
CN110399573A (en) A kind of information processing method, device, equipment and computer readable storage medium
CN113992748A (en) Reverse proxy method, system, medium, and terminal
CN108920277B (en) Service execution system, method and device and service isolation system
CN114461424A (en) Inter-unit service discovery method, device and system under unitized deployment architecture
CN113590352A (en) Data calling method, device, equipment and readable storage medium
CN112383617A (en) Method, device, terminal equipment and medium for long connection
CN113556370A (en) Service calling method and device
CN110855764A (en) Network traffic scheduling method and device and electronic equipment

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