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

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

Info

Publication number
CN112688977A
CN112688977A CN201910990170.1A CN201910990170A CN112688977A CN 112688977 A CN112688977 A CN 112688977A CN 201910990170 A CN201910990170 A CN 201910990170A CN 112688977 A CN112688977 A CN 112688977A
Authority
CN
China
Prior art keywords
service
micro
service system
microservice
proxy
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.)
Granted
Application number
CN201910990170.1A
Other languages
Chinese (zh)
Other versions
CN112688977B (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

A micro-service communication method is disclosed, which is applied to a micro-service system deployed across networks, wherein 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 transmitted calling request from a micro service consumer in the first micro service system through a mounted proxy service; wherein the proxy service is subscribed to the microservice provided by the second microservice system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system; responding to the calling request, and acquiring a calling response corresponding to the calling 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 the micro-service communication between the micro-service systems deployed across the network, so that the repeated deployment of the micro-service systems is avoided, and the efficiency of development, operation and maintenance of the user based on the micro-service is improved.

Description

Micro-service communication method and device, electronic equipment and machine-readable storage medium
Technical Field
The present application relates to the field of computer application technologies, and in particular, to a method and an apparatus for micro-service communication, an electronic device, and a machine-readable storage medium.
Background
In the background of the conventional IT technology, a business system of a company is generally formed by stacking a plurality of software subsystems with independent services, and as the business of the company develops and changes, the business system becomes more complex, thereby causing the problems of high maintenance cost, poor expandability and the like of the business system. With the continuous development and progress of the IT industry, the problems can be effectively solved by developing a business system based on a micro-service architecture.
The micro-service architecture is an emerging architecture technology for developing and deploying a business system based on a cloud computing technology so as to provide a subdivision business service for a user. In practical application, a micro service system can be constructed based on a 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 further construct the service system based on micro services 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 intranet and the second intranet are isolated from each other by the intranet, and the first micro-service system and the second micro-service system are respectively loaded with application program coordination services for micro-service management; the method comprises the following steps:
the method comprises the steps that a first micro service system receives a transmitted calling request from a micro service consumer in the first micro service system through a mounted proxy service; wherein the proxy service is subscribed to the microservice provided by the second microservice system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
responding to the calling request, and acquiring a calling response corresponding to the calling request from the second micro-service system by the proxy service;
and forwarding the call 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 the network.
Optionally, before the proxy service receives the sent invocation request from the micro service consumer in the first micro service system, the method further includes:
and through an application program coordination service carried by the second micro service system, the proxy service subscribes to the micro service of the second micro service system.
Optionally, the coordinating a service through an application program installed in the second micro service system, where the proxy service subscribes to the micro service of the second micro service system, includes:
coordinating services through 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;
and the proxy service acquires the published micro service in the second micro service system from a micro service provider in the second micro service system.
Optionally, the method further includes:
through an application program coordination service carried by the first micro service system, 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 customer in the first micro service system to obtain the service interface.
Optionally, the coordinating the service through the application program installed in the second micro service system, where the proxy service is registered as a micro service consumer of the second micro service system, includes:
through the coordination service of the application program carried by the second micro service system, the proxy service and the second micro service system establish network long connection for safe communication passing through the first intranet and the second intranet;
based on the network long connection, the proxy service registers as a microservice consumer of the second microservice system.
Optionally, the micro-service system is a distributed system providing RPC service based on a Dubbo framework.
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 intranet and the second intranet are isolated from each other by the intranet, and the first micro-service system and the second micro-service system are respectively loaded with application program coordination services for micro-service management; the device comprises:
the system comprises a receiving module, a first micro service system and a second micro service system, wherein the first micro service system receives a calling request sent by a micro service consumer in the first micro service system through a mounted proxy service; wherein the proxy service is subscribed to the microservice provided by the second microservice system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
the obtaining module is used for responding to the calling request, and obtaining a calling response corresponding to the calling request from the second micro-service system by the proxy service;
and the forwarding module forwards the calling response to the micro-service consumers in the first micro-service system so as to complete the micro-service communication between the micro-service systems deployed across the network.
Optionally, before the proxy service receives the sent invocation request from the micro service consumer in the first micro service system, the method further includes:
and the subscription and release module is used for coordinating services through an application program carried by the second micro service system, and the proxy service is subscribed to the micro service of the second micro service system.
Optionally, the subscription publishing module further:
coordinating services through 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;
and the proxy service acquires the published micro service in the second micro service system from a micro service provider in the second micro service system.
Optionally, the subscription publishing module further:
through an application program coordination service carried by the first micro service system, 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 customer in the first micro service system to obtain the service interface.
Optionally, the subscription publishing module further:
through the coordination service of the application program carried by the second micro service system, the proxy service and the second micro service system establish network long connection for safe communication passing through the first intranet and the second intranet;
based on the network long connection, the proxy service registers as a microservice consumer of the second microservice system.
Optionally, the micro-service system is a distributed system providing RPC service based on a Dubbo framework.
Optionally, the application coordination service is a ZooKeeper service.
The application also provides an electronic device, which comprises a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are mutually connected through the bus;
the memory stores machine-readable instructions, and the processor executes the method by calling the machine-readable instructions.
The present application also provides a machine-readable storage medium having stored thereon machine-readable instructions which, when invoked and executed by a processor, implement the above-described method.
Through the above embodiment, based on the proxy service carried by the first micro service system in the micro service systems deployed across the network; and the proxy service agent obtains a calling response corresponding to the calling request from the second micro service system from the service consumer in the first micro service system, and forwards the calling response to the corresponding service consumer in the first micro service system, so that micro service communication among a plurality of micro service systems deployed across a network is realized, the micro services provided by different existing micro service systems are fully utilized, the micro service system is prevented from being deployed repeatedly, and the efficiency of development, operation and maintenance of a user based on the micro services 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 microservice systems deployed across a network, according to 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, according to an exemplary embodiment;
FIG. 5 is a hardware block diagram of an electronic device provided by an exemplary embodiment;
fig. 6 is a block diagram of a microservice communication device provided by an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the 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 and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In order to make those skilled in the art better understand the technical solution in the embodiment of the present disclosure, a brief description will be given below of the related art of micro service communication related to the embodiment of the present disclosure.
Referring to fig. 1, fig. 1 is a networking diagram of a microservice system according to an embodiment of the present disclosure.
The microservice system shown in fig. 1 includes: application coordination services, P, C; wherein, P represents a micro-service provider in the micro-service system, C represents a micro-service consumer in the micro-service system; the micro-service provider and the micro-service consumer perform management and maintenance through the application coordination service.
As shown in fig. 1, the micro service provider P and the micro service consumer C coordinate to complete information interaction through the application coordination service, which mainly includes 3 steps: 1. declaring a service; 2. discovering a service; 3. calling a service;
the step 1, declaring the service refers to that the micro service provider P declares a service interface which can be provided by the micro service provider P through an application program coordination service; step 2, discovering service refers to that the micro service consumer C discovers the service interface declared by the micro service provider P through an application program coordinating service; step 3, calling service means that the micro service consumer C calls the declared service interface of the micro service provider P, and after the micro service provider P executes the micro service processing corresponding to the service interface, the micro service provider P returns the calling response corresponding to the service interface to the micro service consumer C.
It should be noted that, for a detailed interaction process of the micro service system shown in fig. 1, please refer to the description of the micro service system technology, which is not described herein again.
Referring to fig. 2, fig. 2 is a networking diagram of multiple microservices systems deployed across a network according to an embodiment of the present disclosure.
The networking shown in fig. 2 includes: SystemA, SystemB; wherein, system a and system B are micro service systems deployed with different intranets (intranet a and intranet B) and isolated from the intranets, respectively; the networking architecture of a single micro service system, which is indicated by SystemA and SystemB respectively, is the same as the networking architecture of the micro service system shown in fig. 1, and is not described herein again, but only the names of the micro service consumers, the micro service providers, and the application program coordination service are different.
As shown in fig. 2, the micro service system SystemA includes: application coordination services A, P1, C1; wherein, P1 represents the micro service provider in the micro service system, C1 represents the micro service consumer in the micro service system; the micro service provider and the micro service consumer perform management and maintenance through the application coordination service A.
As shown in fig. 2, the micro service system SystemB includes: application coordination services B, P2, C2; wherein, P2 represents the micro service provider in the micro service system, C2 represents the micro service consumer in the micro service system; and the micro service provider and the micro service consumer perform management and maintenance through the application program coordination service B.
On the basis of the networking architecture shown above, the present specification aims to provide a technical solution for performing micro-service communication between cross-network deployed micro-service systems.
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 from each other by the intranet, and the first micro-service system and the second micro-service system are respectively loaded with application program coordination services for micro-service management.
Further, the first micro service system receives a transmitted calling request from a micro service consumer in the first micro service system through the carried proxy service; the agent service subscribes to the micro service provided by the second micro service system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
further, responding to the calling request, and obtaining a calling response corresponding to the calling request from the second micro service system by the proxy service; and forwarding the call response to the micro-service consumer in the first micro-service system so as to complete the micro-service communication between the micro-service systems deployed across the network.
In the technical scheme, the method is based on the proxy service carried by the first micro service system in the cross-network deployed micro service systems; and the proxy service agent obtains a calling response corresponding to the calling request from the second micro service system from the calling request of the service consumer in the first micro service system, and forwards the calling response to the service consumer in the corresponding first micro service system, so that the micro service communication among a plurality of micro service systems deployed across the network is realized, the micro services provided by different existing micro service systems are fully utilized, the micro service system is prevented from being repeatedly deployed, and the efficiency of developing, operating and maintaining based on the micro services by the user is improved.
The present specification is described below with reference to specific embodiments and specific application scenarios.
Referring to fig. 3, fig. 3 is a flowchart of a method for micro-service communication according to an embodiment of the present disclosure, where the method is applied to a cross-network deployed micro-service system, and the micro-service system includes at least 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 from each other by the intranet, and the first micro service system and the second micro service system are respectively loaded with application program coordination service for micro service management; the method comprises 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; the agent service subscribes to the micro service provided by the second micro service system; the invocation request includes at least a service interface corresponding to the microservice provided by the second microservice system.
And 304, responding to the calling request, and acquiring a calling response corresponding to the calling request from the second micro-service system by the proxy service.
And step 306, forwarding the calling response to the micro-service consumers in the first micro-service system so as 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 perform management and maintenance through the application program coordination service. The microserver can invoke the microserver provided by the microserver provider through the application coordination service, and for the specific process, please refer to the detailed description of the microserver system shown in fig. 1, which is not described herein again.
In this specification, the application coordination service refers to distributed management software for performing microservice management in a single microservice system.
In one embodiment, 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 introduction of the ZooKeeper service, please refer to the ZooKeeper technical description, which is not described herein.
Of course, in practical applications, the application coordination service may also be other services, for example, the application coordination service may also be a Nacos service or a Redis service, for which reference is specifically made to technical descriptions of the Nacos service and the Redis service, which are not described herein again.
In this 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 in which the first micro service system is deployed correspondingly.
For example, as shown in fig. 2, the first micro service system may be a micro service system SystemA deployed in an intranet a, or may be a micro service system SystemB deployed in an intranet B.
In this 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 in which the second micro service system is deployed correspondingly.
For example, as shown in fig. 2, the second micro service system may be a micro service system SystemB deployed in an intranet B, or a micro service system SystemA deployed in an intranet a.
The first intranet corresponding to the first microservice system and the second intranet corresponding to the second microservice system are isolated from each other by an intranet.
For example, as shown in fig. 2, the intranet a and the intranet B corresponding to the micro service system SystemA and the micro service system SystemB, respectively, are isolated from each other, that is, the member in the micro service system SystemA and the member in the micro service system SystemB cannot directly perform micro service communication.
In this specification, the micro service system refers to a plurality of micro service systems deployed in different intranets and isolated from each other by 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 loaded with the application coordination service for micro service management.
For example, as shown in fig. 2, the micro service system includes a micro service system SystemA and a micro service system SystemB; the intranet A and the intranet B which are correspondingly deployed by the micro service system SystemA and the micro service system SystemB are isolated by the intranet; the micro service system SystemA and the micro service system SystemB are respectively loaded with an application coordination service a and an application coordination service B for micro service management.
In one embodiment, the micro service system is a distributed system based on a Dubbo framework and providing RPC (Remote Procedure Call) service; for a detailed description of the Dubbo framework and the RPC service, please refer to the related art description, which is not repeated herein.
Of course, the microservice system may also provide other distributed systems of microservices, and the type of microservice provided by the microservice system is not particularly limited in this specification.
Referring to fig. 4, fig. 4 is a networking diagram of multiple microservice systems deployed across a network according to another embodiment of the present disclosure.
The specific components of the networking architecture of the microservice system shown in fig. 4 are the same as those described in detail in fig. 2, and are not described herein again.
FIG. 4 is based on a variation of FIG. 2, with FIG. 4 being substantially the same as FIG. 2 except that FIG. 4 has been augmented with FIG. 2 by an A1; wherein, a1 is a microservice provider in microservice system SystemA and a microservice consumer in microservice system SystemB.
As shown in steps S1 to S6 of fig. 4, a1 provides a communication procedure for calling the microservice of the microservice provider C1 in the microservice system SystemA for the microservice consumer C1 in the microservice system SystemA.
For convenience of understanding, the overall flow of the micro service communication shown in fig. 4 is briefly introduced here, mainly including 6 steps S1 to S6;
the step "s 1, declare service" means that the micro service provider P2 in the micro service system SystemB declares a service interface that can be provided by itself through the application coordination service B; the step of "S2. discovery service" means that A1 discovers the service interface declared by the microservice provider P2 through the application coordination service B; step S3, declaring service means that A1 declares a service interface which can be provided by the A through application program coordination service A; the step of discovering service is that the micro service consumer C1 discovers the declared service interface of A1 through the application program coordination service A; the step of calling the service is that the micro-service consumer C1 completes the calling of the micro-service by calling the declared service interface A1; the step "s 6. call service" refers to a micro service call to the micro service consumer C1, and correspondingly, a1 calls the declared service interface of P2 to execute the corresponding micro service call, and after the micro service provider P2 executes the micro service process corresponding to the service interface, the call response corresponding to the service interface is returned to the micro service consumer C1 via a 1.
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 SystemA shown in fig. 4 and the second micro service system being the micro service system SystemB shown in fig. 4.
In this specification, the proxy service refers to a service component that is installed in each of the microservice systems and performs cross-network microservice communication.
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 microserver in the first one of the microservers.
For another example, in practical applications, the proxy service may be a micro service provider in the first micro service system in the micro service system; and as a microserver in the second one of the microservers.
For convenience of understanding and description, the proxy service is used as a micro-service provider in the first micro-service system in the micro-service system; and, as a microserver in the second microserver system in the microserver system, an example description is made.
In this specification, the first microservice system receives a call request sent from a microservice consumer in the first microservice system through the proxy service installed in the first microservice system; wherein, the agent service subscribes to the micro service provided by the second micro service system; the calling request at least comprises a service interface corresponding to the 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 the microservice system SystemA; among them, the proxy service a1 subscribes to the microservice provided by the microservice provider P2 in the microservice system SystemB. The proxy service a1 receives the sent invocation request from the microserver C1 in the microservice system SystemA; 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 RPC service, please refer to RPC technical description, which is not described herein again).
In one embodiment, before the proxy service receives the call request transmitted from the microserver in the first microserver system, the proxy service subscribes to the microserver of the second microserver system through an application coordination service installed in the second microserver system.
Continuing the example from the above example, referring to fig. 4, before the proxy service a1 receives the call request sent from the microserver C1 of the microserver system SystemA, the proxy service a1 subscribes to the microserver provided by the microserver provider P2 of the microserver system B corresponding to the call request through the application coordination service B hosted by the microserver system B.
In one embodiment, when the agent service is subscribed to the microservice of the second microservice system by the application coordination service installed in the second microservice system, the agent service is registered as a microservice consumer of the second microservice system by the application coordination service installed in the second microservice system.
Continuing the example from 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 systembi through the application coordination service B hosted by the micro service system systembi, the proxy service a1 is registered as the micro service consumer of the micro service system systembi through the application coordination service B hosted by the micro service system systembi.
In one embodiment, the proxy service establishes a long-haul network connection for secure communication with the second microservice system via the first intranet and the second intranet by the application coordination service installed in the second microservice system during registration of the application coordination service installed in the second microservice system as a microservice consumer of the second microservice system.
Continuing the example from the above example, referring to step S2 shown in fig. 4, in the process that the proxy service a1 registers as the microserver of the microserver system B through the application coordination service B loaded by the microserver system B, the proxy service a1 establishes a network long connection for secure communication through the intranet a and the intranet B with the microserver system B through the application coordination service B loaded by the microserver system B; before the network long connection is established, a specific IP address, a port, and the like for performing long connection communication between the proxy service a1 and the micro service system SystemB may be set based on preset user configuration.
It should be noted that the network long connection is a TCP long connection based on RPC service; for a detailed concept and technical principle of TCP long connection, please refer to the technical description of TCP long connection, which is not described herein again.
In this specification, the proxy service is registered as a microserver of the second microserver system based on the long network connection.
Continuing the example from the above example, referring to the step of S2 shown in fig. 4, proxy service a1 is the microserver of microserver system SystemB based on the above described network long connection.
In this specification, after the proxy service is registered as a microservice consumer of the second microservice system, the proxy service may invoke microservice provided by a microservice provider in the second microservice system.
Continuing the example from the above example, referring to steps S2-S6 shown in fig. 4, after proxy service a1 is the microserver of microserver system SystemB, proxy service a1 may invoke the microserver provided by microserver P2 in microserver system SystemB.
Certainly, in practical applications, the proxy service may also be based on related tools of the JAVA technology (for example, may include a JAVA ssist byte toolkit), and the service interface corresponding to the micro service in the micro service system SystemB is led to the micro service system SystemA at one time by acquiring the interface class corresponding to the micro service that can be provided by the micro service system SystemB and the implementation class corresponding to the interface class, for a specific tool of the JAVA technology, please refer to the JAVA technical description, which is not described herein again.
In one embodiment, after the proxy service subscribes to the microservice of the second microservice system, the proxy service is registered as a microservice provider of the first microservice system by an application coordination service installed in the first microservice system.
Continuing with the example above, referring to steps S1 to S3 shown in fig. 4, after the proxy service a1 subscribes to the microservice of the microservice system systemba, the proxy service is registered as a microservice provider of the microservice system systemba through the application coordination service a hosted by the microservice system systemba.
In this specification, the proxy service distributes a service interface corresponding to a published micro service in the second micro service system to the first micro service system, so that a consumer in the first micro service system can obtain the service interface.
Continuing the example from the above example, referring 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 SystemB in the micro service system SystemA so as to be obtained by the consumer C1 in the micro service system SystemA.
In this specification, after receiving the call request, the proxy service acquires a call response corresponding to the call request from the second microservice system in response to the call request.
Continuing the example from the above example, referring to steps S5 to S6 shown in fig. 4, after receiving a call request that C1 wants to call a service interface corresponding to the P2 microservice, the proxy service a1 continues to call the microservice provided by the P2 corresponding to the call request from the microservice system SystemB; and acquiring a call response corresponding to the microservice provided by the P2.
In this specification, further, the proxy service forwards the call response to the microserver in the first microserver system, so as to complete microserver communication between microserver systems deployed across a network.
Continuing the example from the above example, the proxy service a1 forwards the call response provided by the P2 in the microservice system SystemB and corresponding to the call request to the C1 in the microservice system SystemB to complete microservice communication between the microservice systems deployed across the network.
In the technical scheme, the method is based on the proxy service carried by the first micro service system in the cross-network deployed micro service systems; and the proxy service agent obtains a calling response corresponding to the calling request from the second micro service system from the calling request of the service consumer in the first micro service system, and forwards the calling response to the service consumer in the corresponding first micro service system, so that the micro service communication among a plurality of micro service systems deployed across the network is realized, the micro services provided by different existing micro service systems are fully utilized, the micro service system is prevented from being repeatedly deployed, and the efficiency of developing, operating and maintaining based on the micro services by the user is improved.
Corresponding to the method embodiment, the application also provides an embodiment of the micro-service communication device.
Corresponding to the method embodiment, the present specification also provides an embodiment of a microservice communication device. The embodiment of the microserver communication device of the present specification can be applied to electronic equipment. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a logical device, the device is formed by reading, by a processor of the electronic device where the device is located, a corresponding computer program instruction in the nonvolatile memory into the memory for operation. From a hardware aspect, as shown in fig. 5, the hardware structure diagram of the electronic device in which the micro service communication apparatus of this specification is located is shown in fig. 5, except for the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 5, the electronic device in which the apparatus is located in the embodiment may also include other hardware according to the actual function of the electronic device, which is not described again.
Fig. 6 is a block diagram of a microservice communication device shown in an exemplary embodiment of the present description.
Referring to fig. 6, the microservice communication device 60 can be applied to the electronic device shown in fig. 5, and the device is applied to a microservice 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 intranet and the second intranet are isolated from each other by the intranet, and the first micro service system and the second micro service system are respectively loaded with application program coordination service for micro service management; the device includes:
a receiving module 601, where the first micro service system receives a call request sent by a micro service consumer in the first micro service system through a mounted proxy service; the agent service subscribes to the micro service provided by the second micro service system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
the obtaining module 602, responding to the call request, obtaining, by the proxy service, a call response corresponding to the call request from the second microservice system;
the forwarding module 603 forwards the call response to the microserver in the first microserver system to complete microserver communication between the microserver systems deployed across the network.
In this embodiment, before the proxy service receives the sent invocation request from the microserver in the first microserver system, the method further includes:
the subscription and publishing module 604 coordinates the service through the application program installed in 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 microservices in the second microservice system from the microservice provider in the second microservice system.
In this embodiment, the subscription publishing module 604 further:
the agent service is registered as a micro service provider of the first micro service system through the application program coordination service carried by the first micro service system;
and releasing the service interface corresponding to the released 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.
In this embodiment, the subscription publishing module 604 further:
through the coordination service of the application program carried by the second micro service system, the proxy service and the second micro service system establish network long connection for safe communication passing through the first intranet and the second intranet;
the proxy service registers as a microservice consumer of the second microservice system based on the network long connection.
In the embodiment, the micro service system is a distributed system providing RPC service based on the Dubbo framework.
In this embodiment, the application coordination service is a ZooKeeper service.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
The apparatuses, modules or modules illustrated in the above embodiments may be implemented by a computer chip or an entity, or by an article with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
Corresponding to the method embodiment, 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 intranet and the second intranet are isolated from each other by the intranet, and the first micro service system and the second micro service system are respectively loaded 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:
the method comprises the steps that a first micro service system receives a transmitted calling request from a micro service consumer in the first micro service system through a mounted proxy service; the agent service subscribes to the micro service provided by the second micro service system; the calling 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 call response to the micro-service consumer in the first micro-service system so as to complete the micro-service communication between the micro-service systems deployed across the network.
In this embodiment, prior to the proxy service receiving a transmitted invocation request from a microservice consumer in the first microservice system, the processor is caused to, by reading and executing memory-stored machine-executable instructions corresponding to control logic of the microservice communication:
and the proxy service subscribes the micro service of the second micro service system through the application program coordination service carried by the second micro service system.
In this embodiment, the processor is caused to:
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 microservices in the second microservice system from the microservice provider in the second microservice system.
In this embodiment, the processor is caused to:
the agent service is registered as a micro service provider of the first micro service system through the application program coordination service carried by the first micro service system;
and releasing the service interface corresponding to the released 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.
In this embodiment, the processor is caused to:
through the coordination service of the application program carried by the second micro service system, the proxy service and the second micro service system establish network long connection for safe communication passing through the first intranet and the second intranet;
the proxy service registers as a microservice consumer of the second microservice system based on the network long connection.
In the embodiment, the micro service system is a distributed system providing RPC service based on the Dubbo framework.
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 disclosure 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 will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, 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 above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

Claims (10)

1. A micro-service communication 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 intranet and the second intranet are isolated from each other by the intranet, and the first micro-service system and the second micro-service system are respectively loaded with application program coordination services for micro-service management; the method comprises the following steps:
the method comprises the steps that a first micro service system receives a transmitted calling request from a micro service consumer in the first micro service system through a mounted proxy service; wherein the proxy service is subscribed to the microservice provided by the second microservice system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
responding to the calling request, and acquiring a calling response corresponding to the calling request from the second micro-service system by the proxy service;
and forwarding the call 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 the network.
2. The method of claim 1, further comprising, before the proxy service receives a sent invocation request from a microservice consumer in the first microservice system:
and through an application program coordination service carried by the second micro service system, the proxy service subscribes to the micro service of the second micro service system.
3. The method of claim 2, the application coordination service hosted by the second microservice system, the broker service subscribed to microservices of the second microservice system, comprising:
coordinating services through 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;
and the proxy service acquires the published micro service in the second micro service system from a micro service provider in the second micro service system.
4. The method of claim 3, further comprising:
through an application program coordination service carried by the first micro service system, 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 customer in the first micro service system to obtain the service interface.
5. The method of claim 3, the application orchestration service hosted by the second microservice system, the broker service registered as a microservice consumer of the second microservice system, comprising:
through the coordination service of the application program carried by the second micro service system, the proxy service and the second micro service system establish network long connection for safe communication passing through the first intranet and the second intranet;
based on the network long connection, the proxy service registers as a microservice consumer of the second microservice system.
6. The method of claim 1, the microservice system being a distributed system providing RPC services based on the Dubbo framework.
7. The method of claim 1, the application coordination service being a ZooKeeper service.
8. A micro-service communication device, the device is 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 intranet and the second intranet are isolated from each other by the intranet, and the first micro-service system and the second micro-service system are respectively loaded with application program coordination services for micro-service management; the device comprises:
the system comprises a receiving module, a first micro service system and a second micro service system, wherein the first micro service system receives a calling request sent by a micro service consumer in the first micro service system through a mounted proxy service; wherein the proxy service is subscribed to the microservice provided by the second microservice system; the calling request at least comprises a service interface corresponding to the micro service provided by the second micro service system;
the obtaining module is used for responding to the calling request, and obtaining a calling response corresponding to the calling request from the second micro-service system by the proxy service;
and the forwarding module forwards the calling response to the micro-service consumers in the first micro-service system so as to complete the micro-service communication between the micro-service systems deployed across the network.
9. 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 has stored therein machine-readable instructions, the processor executing the method of any of claims 1 to 7 by calling the machine-readable instructions.
10. A machine readable storage medium having stored thereon machine readable instructions which, when invoked and executed by a processor, carry out the method of any of claims 1 to 7.
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 true CN112688977A (en) 2021-04-20
CN112688977B 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 (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120135726A1 (en) * 2010-07-26 2012-05-31 Michael Luna Mobile application traffic optimization
CN103220292A (en) * 2013-04-22 2013-07-24 广东电网公司电力科学研究院 Cross-safe-area data transmission method and system
US20180198845A1 (en) * 2017-01-09 2018-07-12 International Business Machines Corporation Local Microservice Development for Remote Deployment
US20180331905A1 (en) * 2017-05-11 2018-11-15 Nirmata, Inc. Method and system for tuning performance of microservices-based applications
CN109618005A (en) * 2019-01-18 2019-04-12 华为终端有限公司 Method for calling server and proxy server
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium
US20190199738A1 (en) * 2017-12-21 2019-06-27 International Business Machines Corporation Microservice integration fabrics network intrusion detection and prevention service capabilities
CN110225131A (en) * 2019-06-19 2019-09-10 广州小鹏汽车科技有限公司 A kind of service calling method and device
CN110247944A (en) * 2018-03-09 2019-09-17 阿里巴巴集团控股有限公司 Trans-regional service calling method, device, system and electronic equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120135726A1 (en) * 2010-07-26 2012-05-31 Michael Luna Mobile application traffic optimization
CN103220292A (en) * 2013-04-22 2013-07-24 广东电网公司电力科学研究院 Cross-safe-area data transmission method and system
US20180198845A1 (en) * 2017-01-09 2018-07-12 International Business Machines Corporation Local Microservice Development for Remote Deployment
US20180331905A1 (en) * 2017-05-11 2018-11-15 Nirmata, Inc. Method and system for tuning performance of microservices-based applications
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium
US20190199738A1 (en) * 2017-12-21 2019-06-27 International Business Machines Corporation Microservice integration fabrics network intrusion detection and prevention service capabilities
CN110247944A (en) * 2018-03-09 2019-09-17 阿里巴巴集团控股有限公司 Trans-regional service calling method, device, system and electronic equipment
CN109618005A (en) * 2019-01-18 2019-04-12 华为终端有限公司 Method for calling server and proxy server
CN110225131A (en) * 2019-06-19 2019-09-10 广州小鹏汽车科技有限公司 A kind of service calling method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
超级程序员: "dubbo学习总结之RPC", 《CSDN》 *

Also Published As

Publication number Publication date
CN112688977B (en) 2023-06-16

Similar Documents

Publication Publication Date Title
US8788580B2 (en) Event broker for an improved application server platform for telecom-based applications
EP3138003B1 (en) System and method for supporting a bypass-domain model and a proxy model and updating service information for across-domain messaging in a transactional middleware machine environment
US10127091B1 (en) Intercepting socket metadata
CN111163130B (en) Network service system and data transmission method thereof
CN113746928B (en) Cross-cloud service calling method, device and system
US8533748B2 (en) Contained command invocation framework
US8589956B2 (en) Method and apparatus for providing application with interface to composite network service
CN114189525B (en) Service request method and device and electronic equipment
CN110007936B (en) Data processing method and device
CN104503768A (en) Call method and device for application programming interface (API)
CN106357654B (en) Remote procedure calling method, device and communication system
CN112751935B (en) Request processing method and device, electronic equipment and storage medium
CN112698930B (en) Method, device, equipment and medium for obtaining server identification
CN109445960B (en) Application routing method, device and storage medium
CN106980534B (en) Service execution method and device based on SDK (software development kit) component
CN112688977A (en) Micro-service communication method and device, electronic equipment and machine-readable storage medium
CN115629809A (en) Data processing method and device, electronic equipment and computer readable storage medium
Frei et al. A dynamic lightweight platform for ad-hoc infrastructures
CN111866157B (en) Cloud service gateway and cloud service internal and external request format conversion method
CN108920277B (en) Service execution system, method and device and service isolation system
Vekshyn et al. Algorithmic software adaptation approach in mobile augmented reality systems
CN112333270B (en) Method and system for dynamic routing of micro-services
CN114039977B (en) Method, system and device for realizing application task based on edge calculation
CN114331447B (en) Cross-link message submitting method and device
CN116467092A (en) Service logic processing method and device, electronic equipment and storage medium

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