Service distribution method and apparatus based on remote procedure call, medium, and device

By acquiring common business logic code and factory class proxies, transparent service distribution across JVMs is achieved, solving the technical problem of service distribution in microservice architecture and supporting service distribution within the same virtual machine and across JVMs.

CN115421936BActive Publication Date: 2025-11-18BEIJING SHENZHOU AEROSPACE SOFTWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211051994.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-30
Publication Date
2025-11-18
Estimated Expiration
2042-08-30

AI Technical Summary

Technical Problem

In a microservice architecture, there are technical challenges in service distribution between microservices. Traditional methods can only be completed within the monolithic application server runtime environment and cannot perform service distribution transparently and seamlessly across JVMs.

Method used

By obtaining the common business logic code in the software function code to be called, using the factory class to obtain the local proxy of the service interface, and executing the local call or remote procedure call based on whether the calling method and the business implementation are on the same server, transparent service distribution across JVMs is achieved.

Benefits of technology

It supports service distribution within the same virtual machine and across JVMs. The service distribution process is transparent and seamless to the upper-layer caller, overcoming the limitations of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115421936B_ABST
    Figure CN115421936B_ABST
Patent Text Reader

Abstract

Disclosed are a service distribution method and device based on remote procedure call, a medium and equipment, the method comprising: acquiring general business logic code in software function code to be called, wherein, in the software function code to be called, a business logic part that is not passed through by a business object is replaced by a service interface; acquiring a local agent of the service interface of the software function code to be called through a factory class; and performing local calling or remote procedure calling according to whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, to realize service distribution of the business object in the service. The device, medium and equipment can be used to realize the method. They can support service distribution within the same virtual machine and also support service distribution across JVMs, and the service distribution process is transparent and imperceptible to the upper-layer service calling party regardless of whether the service distribution is across JVMs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer program data management technology, and in particular to a service distribution method, apparatus, medium and device based on remote procedure call. Background Technology

[0002] In application server software development, it is often necessary to modify the business logic based on different business objects, that is, to distribute software services according to business objects to meet software functional requirements. In a monolithic service architecture, service distribution is completed in a single runtime environment. However, in a microservice architecture, the business logic is distributed across different services, presenting technical challenges in distributing services between microservices. Summary of the Invention

[0003] In view of this, the present invention provides a service distribution method, apparatus, medium and device based on remote procedure calls, which can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, thus making it more suitable for practical use.

[0004] To achieve the first objective mentioned above, the technical solution of the service distribution method based on remote procedure call provided by this invention is as follows:

[0005] The service distribution method based on remote procedure call provided by this invention includes the following steps:

[0006] Obtain the general business logic code from the software function code to be invoked, wherein the business logic parts that differ due to different business objects in the software function code to be invoked are replaced by service interfaces;

[0007] Obtain a local proxy for the service interface of the software function code to be invoked through a factory class;

[0008] Depending on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed to realize the service distribution of the business object in the service.

[0009] The service distribution method based on remote procedure call provided by this invention can also be further implemented using the following technical measures.

[0010] Preferably, depending on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed to realize the service implementation of the business object in the service. This specifically includes the following steps:

[0011] Determine whether the interface call method and the service implementation are on the same server.

[0012] When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same server, the local call is executed directly on the server.

[0013] When the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called, a remote procedure call is executed.

[0014] Preferably, when the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are on different servers, the execution of the remote procedure call specifically includes the following steps:

[0015] Obtain a remote interface proxy;

[0016] Obtain a local proxy for the service interface of the software function code to be invoked through a factory class;

[0017] Execute local calls to implement the service implementation of business objects within the service.

[0018] Preferably, between the step of obtaining the local proxy of the service interface of the software function code to be called through the factory class and the step of executing the local call to realize the service implementation of the business object in the service, the following steps are also included:

[0019] Determine whether the interface call method and the service implementation are on the same server.

[0020] When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same server, the local call is executed directly on the server.

[0021] When the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called, a remote procedure call is executed.

[0022] Preferably, in the step of obtaining the general business logic code in the software function code to be called, wherein the business logic parts in the software function code to be called that differ due to different business objects are replaced by service interfaces, the service interfaces include one or more of the following: writing a business function interface class, writing a business function interface implementation class, writing a service interface, writing a default implementation class for a service interface, and writing a remote proxy class for service implementation.

[0023] Preferably, in the step of performing a local call or a remote procedure call based on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, thereby realizing the service distribution of the business object in the service, the service distribution content includes configuration information, which includes:

[0024] The service implementation description information for all business objects in the system includes: service implementation identifier, name of the microservice in which the service implementation class is located, and root path of the microservice in which the service implementation class is located.

[0025] The mapping information of the correspondence between the service implementations written by each business object for different services includes: business object type identifier, service name, and service implementation identifier.

[0026] Preferably, in the step of performing a local call or remote procedure call based on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, the criteria for determining whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service include the name of the implementation class of the service interface of the business object, the name of the microservice where the service implementation is located, and the service root path.

[0027] To achieve the second objective mentioned above, the technical solution of the service distribution device based on remote procedure call provided by the present invention is as follows:

[0028] The service distribution device based on remote procedure call provided by this invention includes:

[0029] The object acquisition module is invoked to obtain the general business logic code in the software function code to be invoked. Among them, the business logic parts that are different due to different business objects in the software function code to be invoked are replaced by service interfaces.

[0030] The local proxy acquisition module is used to acquire local proxies for the service interfaces of the software function code to be invoked through a factory class;

[0031] The service distribution module is used to perform local or remote procedure calls based on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, thereby realizing the service distribution of business objects in the service.

[0032] To achieve the third objective mentioned above, the technical solution of the computer-readable storage medium provided by the present invention is as follows:

[0033] The present invention provides a computer-readable storage medium storing a service dispatch program based on remote procedure calls, which, when executed by a processor, implements the steps of the service dispatch method based on remote procedure calls provided by the present invention.

[0034] To achieve the fourth objective mentioned above, the technical solution for the electronic device provided by this invention is as follows:

[0035] The electronic device provided by the present invention includes a memory and a processor. The memory stores a service distribution program based on remote procedure calls. When the service distribution program based on remote procedure calls is executed by the processor, it implements the steps of the service distribution method based on remote procedure calls provided by the present invention.

[0036] The embodiments of this invention relate to a service distribution method, apparatus, medium, and device based on remote procedure calls. Different business objects can provide different service implementations for service interfaces. When a service interface is called in the general logic code, the system automatically finds the service implementation class and its microservice based on the business object type, and then completes the execution of the method in the service interface through remote procedure calls. It can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, thus improving the limitation of traditional service distribution, which can only be completed within the monolithic application server runtime environment. Attached Figure Description

[0037] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0038] Figure 1 A flowchart illustrating the steps of a service distribution method based on remote procedure call provided in an embodiment of the present invention;

[0039] Figure 2 A detailed flowchart of the steps of the service distribution method based on remote procedure call provided in the embodiments of the present invention;

[0040] Figure 3 A schematic diagram illustrating the correspondence between service implementation description information and service-service implementation mapping information involved in the service distribution method based on remote procedure call provided in this embodiment of the invention.

[0041] Figure 4This is a schematic diagram illustrating the signal flow relationship between the functional modules of the service distribution device based on remote procedure call provided in an embodiment of the present invention.

[0042] Figure 5 This is a schematic diagram of the service distribution device structure based on remote procedure call in the hardware operating environment involved in the embodiments of the present invention. Detailed Implementation

[0043] To address the problems existing in the prior art, this invention provides a service distribution method, apparatus, medium, and device based on remote procedure calls. It can support service distribution within the same virtual machine as well as service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, making it more suitable for practical use.

[0044] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation methods, structures, features, and effects of the service distribution method, apparatus, medium, and device based on remote procedure calls proposed according to the present invention. In the following description, different "embodiments" or "embodiments" do not necessarily refer to the same embodiment. Furthermore, features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0045] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships, such as A and / or B. Specifically, it can mean that A and B can be included at the same time, A can exist alone, or B can exist alone, and any of the above three situations can be met.

[0046] In order to provide a technical explanation of the embodiments of the present invention, the relevant technical terms are specifically defined as follows:

[0047] JVM: Short for Java Virtual Machine. It is a specification for computing devices; it is a virtual machine, or virtual computer. The JVM provides a runtime environment for Java programs on different computer operating systems.

[0048] Application service: A computer application that uses a web browser and web technologies to perform tasks on a network. This application can provide pre-coded software functionality to external systems via network requests.

[0049] Monolithic application architecture: A software system architecture in which there is only one application service, and all software functions are provided by this one application service.

[0050] Microservice application architecture: A software system architecture approach that differs from monolithic application architecture. It constructs a software system as a series of independent application services divided according to business domains. Each application service can run independently and implements a single business function.

[0051] Microservices: In a microservice application architecture, each application service is called a microservice. For the entire application system, a microservice only performs a relatively simple business function.

[0052] Service runtime environment: The software environment required to run an application service (or microservice). For application services (or microservices) written in Java, the runtime environment is the JVM in which the application service resides.

[0053] Business objects: Data entities identified and defined according to business domains during the development of computer applications.

[0054] Interface: An interface is a set of method declarations, a collection of method characteristics. An interface only has the characteristics of methods but not their implementations. Therefore, these methods can be implemented by different classes, and these implementations can have different behaviors (functionalities).

[0055] Interface implementation: A class that implements all the methods defined in an interface is called an "interface implementation".

[0056] Service: A service is an interface defined for a specific business function during application service development. This interface contains a series of method declarations related to that business function. "Service" is a term used from the perspective of business function to refer to an interface.

[0057] Service implementation: Service implementation is the interface implementation of a service by a business object. Different business objects may have different service implementations for the same service.

[0058] Service dispatch: Service dispatch is the process of calling different service implementations based on the different types of business objects during application service runtime.

[0059] Remote Procedure Call (RPC) is a method where a function or method on one machine is invoked from another machine by passing parameters, and the returned result is obtained. This method can also be called a service. RPC hides the underlying communication details and does not require direct handling of socket or HTTP communication. RPC is a request-response model. The client initiates a request, and the server returns a response. The request-response process between application services running on different JVMs also falls under the category of remote procedure calls.

[0060] Service dispatching method based on remote procedure call

[0061] See appendix Figure 1 - Appendix Figure 3 The service distribution method based on remote procedure call provided in this embodiment of the invention includes the following steps:

[0062] Step S1: Obtain the general business logic code from the software function code to be called. The business logic parts that differ depending on the business object are represented by service interfaces. Specifically, developers describe the service interfaces, define their names and parameters, and write code according to the software function requirements. Service definitions include: writing the business function interface class (xxxService), the business function interface implementation class (xxxServiceImpl), the service interface (xxxBusiness), the service interface default implementation class (xxxDefaultBussinessImpl), and the service implementation remote proxy class (xxxBusinessController). Developers then write the specific implementation code for the service interface (xxxBusiness) within the microservice where each business object resides, based on the business logic of that business object.

[0063] Step S2: Obtain a local proxy for the service interface of the software function code to be invoked through a factory class; specifically, such as... Figure 3 As shown, developers describe the configuration information required for service distribution through configuration files. The configuration information includes two parts: the first part is the service implementation description information of all business objects in the system, which includes: service implementation identifier, the name of the microservice where the service implementation class is located, and the root path of the microservice where the service implementation class is located; the second part is the mapping information of the correspondence between the service implementations written by each business object for different services, which includes: business object type identifier, service name, and service implementation identifier.

[0064] Step S3: Based on whether the service interface calling method of the software function code to be called and the business implementation in the software function code to be called are in the same service, execute a local call or a remote procedure call to realize the service distribution of the business object in the service. Specifically, when developers write software function code, they only write the common logic part. For the business logic parts that are different due to different business objects, they are uniformly replaced by the service interface (xxxBusiness) defined in step 1. In this way, when writing software function code, there is no need to care about the differences in business objects, because the processing logic of different business objects is abstracted into a unified service interface. The process of calling the service interface in the common logic code is divided into two steps. The first step is to obtain the local proxy of the service interface through the factory class; the second step is to call the method in the local proxy, and the local proxy executes the remote procedure call (or local call) through the following steps and returns the execution result. The system finds the implementation class name of the business object for the service interface, the name of the microservice where the service implementation is located, and the service root path from the configuration information based on the object type and service interface name passed by the caller. Depending on whether the microservice where the service implementation class resides is the same as the microservice where the current caller resides, there are two scenarios: When the service caller and the service implementation are in the same microservice, the service call can be completed directly by executing the method in the interface through a local call. When the service caller and the service implementation are not in the same microservice, a remote procedure call is initiated from the microservice where the service caller resides (the initiator) to the service implementation proxy class in the microservice where the service implementation resides (the receiver). In the service proxy class of the receiver, the local proxy of the service interface is obtained through the factory class, and the interface method is called. The local proxy repeats the process of obtaining the service configuration and determining whether the caller and the service implementation are in the same microservice. In this case, the service caller and the service implementation are definitely in the same microservice, thus the interface method can be called locally. The result is then returned to the upper-level local proxy, which returns this result as the result of the remote call to the initiator, ultimately completing the remote procedure call. By handling the two scenarios separately, regardless of whether the service caller and the service implementer are in the same microservice, the system can use service distribution to call the corresponding service implementation based on the different business objects.

[0065] The embodiments of this invention involve a service distribution method based on remote procedure calls. Different business objects can provide different service implementations for service interfaces. When a service interface is called in the general logic code, the system automatically finds the service implementation class and its microservice based on the business object type. Then, the execution of the method in the service interface is completed through remote procedure calls. It can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller. This improves upon the limitation of traditional service distribution, which can only be completed within the runtime environment of a monolithic application server.

[0066] Specifically, depending on whether the service interface calling method of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed to realize the service implementation of the business object in the service. This includes the following steps:

[0067] Determine whether the API call method and the service implementation are on the same server.

[0068] When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are on the same server, the local call is executed directly on the server.

[0069] Remote procedure call is executed when the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called.

[0070] When the calling method of the service interface of the software function code to be called is located on a different server than the business implementation in the software function code to be called, the execution of a remote procedure call specifically includes the following steps:

[0071] Obtain a remote interface proxy;

[0072] A local proxy is obtained from the service interface of the software function code to be invoked through the factory class;

[0073] Execute local calls to implement the service implementation of business objects within the service.

[0074] The process between obtaining the local proxy of the service interface of the software function code to be called through the factory class and executing the local call to realize the service implementation of the business object in the service also includes the following steps:

[0075] Determine whether the API call method and the service implementation are on the same server.

[0076] When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are on the same server, the local call is executed directly on the server.

[0077] Remote procedure call is executed when the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called.

[0078] In the process of obtaining the general business logic code in the software function code to be called, and in which the business logic parts that differ due to different business objects in the software function code to be called are replaced by service interfaces, the service interfaces include one or more of the following: writing business function interface classes, writing business function interface implementation classes, writing service interfaces, writing default implementation classes of service interfaces, and writing remote proxy classes for service implementation.

[0079] In the process of service distribution of business objects within a service, depending on whether the service interface calling method of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed. The service distribution includes configuration information, which includes:

[0080] The service implementation description information for all business objects in the system includes: service implementation identifier, name of the microservice in which the service implementation class is located, and root path of the microservice in which the service implementation class is located.

[0081] The mapping information of the correspondence between the service implementations written by each business object for different services includes: business object type identifier, service name, and service implementation identifier.

[0082] In the process of determining whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, local calls or remote procedure calls are executed to realize the service distribution of business objects in the service. The criteria for determining whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service include the name of the implementation class of the service interface of the business object, the name of the microservice where the service implementation is located, and the service root path.

[0083] Service distribution device based on remote procedure call

[0084] See appendix Figure 4 The service distribution device based on remote procedure call provided in this embodiment of the invention includes:

[0085] The `Object Acquisition` module retrieves the common business logic code from the software function code to be invoked. Within this code, business logic that differs depending on the business object is represented by a service interface. Specifically, developers describe the service interface, specifying its name and parameters, by writing code based on the software function requirements. The service definition includes: writing the business function interface class (xxxService), the business function interface implementation class (xxxServiceImpl), the service interface (xxxBusiness), the service interface default implementation class (xxxDefaultBussinessImpl), and the service implementation remote proxy class (xxxBusinessController). Developers then write the specific implementation code for the service interface (xxxBusiness) within the microservice where each business object resides, based on the business logic of that business object.

[0086] The local proxy acquisition module is used to obtain local proxies for the service interfaces of the software function code to be invoked through a factory class; specifically, such as... Figure 3 As shown, developers describe the configuration information required for service distribution through configuration files. The configuration information includes two parts: the first part is the service implementation description information of all business objects in the system, which includes: service implementation identifier, the name of the microservice where the service implementation class is located, and the root path of the microservice where the service implementation class is located; the second part is the mapping information of the correspondence between the service implementations written by each business object for different services, which includes: business object type identifier, service name, and service implementation identifier.

[0087] The service distribution module is used to perform local or remote procedure calls based on whether the calling method of the service interface in the software function code to be called and the business implementation in the software function code to be called are in the same service, thus realizing service distribution of business objects within services. Specifically, developers only write the common logic part when writing software function code. For business logic parts that differ due to different business objects, they are uniformly replaced by the service interface (xxxBusiness) defined in step 1. This way, when writing software function code, there is no need to worry about the differences between business objects, because the processing logic of different business objects is abstracted into a unified service interface. The process of calling the service interface in the common logic code is divided into two steps: the first step is to obtain the local proxy of the service interface through the factory class; the second step is to call the method in the local proxy, which executes the remote procedure call (or local call) through the following steps and returns the execution result. The system finds the name of the implementation class of the service interface for the business object, the name of the microservice where the service implementation is located, and the service root path from the configuration information based on the object type and service interface name passed by the caller. Depending on whether the microservice where the service implementation class resides is the same as the microservice where the current caller resides, there are two scenarios: When the service caller and the service implementation are in the same microservice, the service call can be completed directly by executing the method in the interface through a local call. When the service caller and the service implementation are not in the same microservice, a remote procedure call is initiated from the microservice where the service caller resides (the initiator) to the service implementation proxy class in the microservice where the service implementation resides (the receiver). In the service proxy class of the receiver, the local proxy of the service interface is obtained through the factory class, and the interface method is called. The local proxy repeats the process of obtaining the service configuration and determining whether the caller and the service implementation are in the same microservice. In this case, the service caller and the service implementation are definitely in the same microservice, thus the interface method can be called locally. The result is then returned to the upper-level local proxy, which returns this result as the result of the remote call to the initiator, ultimately completing the remote procedure call. By handling the two scenarios separately, regardless of whether the service caller and the service implementer are in the same microservice, the system can use service distribution to call the corresponding service implementation based on the different business objects.

[0088] The embodiments of this invention relate to a service distribution device based on remote procedure calls, which allows different business objects to provide different service implementations for service interfaces. When a service interface is called in the general logic code, the system automatically finds the service implementation class and its microservice based on the business object type, and then completes the execution of the method in the service interface through remote procedure calls. It can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, thus improving the limitation of traditional service distribution, which can only be completed within the runtime environment of a monolithic application server.

[0089] Computer-readable storage media

[0090] The present invention provides a computer-readable storage medium storing a service dispatcher based on remote procedure calls. When the service dispatcher based on remote procedure calls is executed by a processor, it implements the steps of the service dispatcher based on remote procedure calls provided by the present invention.

[0091] The embodiments of this invention involve a computer-readable storage medium in which different business objects can provide different service implementations for service interfaces. When a service interface is called in the general logic code, the system automatically finds the service implementation class and its microservice based on the business object type, and then completes the execution of the method in the service interface through remote procedure call. It can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, thus improving the limitation of traditional service distribution, which can only be completed within the monolithic application server runtime environment.

[0092] electronic devices

[0093] The electronic device provided by the present invention includes a memory and a processor. The memory stores a service dispatch program based on remote procedure calls. When the service dispatch program based on remote procedure calls is executed by the processor, it implements the steps of the service dispatch method based on remote procedure calls provided by the present invention.

[0094] This invention relates to electronic devices where different business objects can provide different service implementations for service interfaces. When a service interface is called in the general logic code, the system automatically finds the service implementation class and its microservice based on the business object type, and then executes the method in the service interface through remote procedure call. It can support service distribution within the same virtual machine or service distribution across JVMs. Regardless of whether the service distribution is across JVMs, the service distribution process is transparent and imperceptible to the upper-layer service caller, thus improving the limitation of traditional service distribution, which can only be completed within the monolithic application server runtime environment.

[0095] Reference Figure 5 , Figure 5 This is a schematic diagram of the service distribution device structure based on remote procedure call in the hardware operating environment involved in the embodiments of the present invention.

[0096] like Figure 5 As shown, the service distribution device based on remote procedure call may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0097] Those skilled in the art will understand that Figure 5 The structure shown does not constitute a limitation on a service distribution device based on remote procedure calls, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0098] like Figure 5 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a service dispatcher based on remote procedure calls.

[0099] exist Figure 5 In the remote procedure call-based service distribution device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the remote procedure call-based service distribution device of the present invention can be set in the remote procedure call-based service distribution device. The remote procedure call-based service distribution device calls the remote procedure call-based service distribution program stored in the memory 1005 through the processor 1001 and executes the remote procedure call-based service distribution method provided in the embodiment of the present invention.

[0100] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention.

[0101] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A service distribution method based on remote procedure call, characterized in that, Includes the following steps: Obtain the general business logic code from the software function code to be invoked, wherein the business logic parts that differ due to different business objects in the software function code to be invoked are replaced by service interfaces; Obtain a local proxy for the service interface of the software function code to be invoked through a factory class; Depending on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed to realize the service distribution of the business object in the service; Depending on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, a local call or a remote procedure call is executed to realize the service implementation of the business object in the service. Specifically, this includes the following steps: Determine whether the interface call method and the service implementation are on the same server. When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same server, the local call is executed directly in the server. When the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called, a remote procedure call is executed. Specifically, a remote procedure call is initiated from the initiator of the microservice where the service caller is located to the service implementation proxy class in the receiver of the microservice where the service implementation is located. In the service proxy class of the receiver, the local proxy of the service interface is obtained through the factory class and the interface method is called. The local proxy repeats the process of obtaining the service configuration and determining whether the caller and the service implementation are in the same microservice. At this time, the service caller and the service implementation are definitely in the same microservice, so the call to the interface method is completed through local call. Then the result is returned to the upper local proxy. The upper local proxy returns this result as the result of the remote call to the initiator, and finally the remote procedure call is completed.

2. The service distribution method based on remote procedure call according to claim 1, characterized in that, When the calling method of the service interface of the software function code to be called is located on a different server than the business implementation in the software function code to be called, the execution of the remote procedure call specifically includes the following steps: Obtain a remote interface proxy; Obtain a local proxy for the service interface of the software function code to be invoked through a factory class; Execute local calls to implement the service implementation of business objects within the service.

3. The service distribution method based on remote procedure call according to claim 2, characterized in that, Between the step of obtaining the local proxy of the service interface of the software function code to be called through the factory class and the step of executing the local call to realize the service implementation of the business object in the service, the following steps are also included: Determine whether the interface call method and the service implementation are on the same server. When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same server, the local call is executed directly in the server. When the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called, a remote procedure call is executed.

4. The service distribution method based on remote procedure call according to claim 1, characterized in that, In the step of obtaining the general business logic code in the software function code to be called, wherein the business logic parts that differ due to different business objects in the software function code to be called are replaced by service interfaces, the service interfaces include one or more of the following: writing a business function interface class, writing a business function interface implementation class, writing a service interface, writing a default implementation class for the service interface, and writing a remote proxy class for the service implementation.

5. The service distribution method based on remote procedure call according to claim 1, characterized in that, In the step of determining whether the service interface in the software function code to be invoked and the business implementation in the software function code to be invoked are in the same service, and executing a local call or a remote procedure call to realize the service distribution of the business object in the service, the service distribution content includes configuration information, which includes: The service implementation description information for all business objects in the system includes: service implementation identifier, name of the microservice in which the service implementation class is located, and root path of the microservice in which the service implementation class is located. The mapping information of the correspondence between the service implementations written by each business object for different services includes: business object type identifier, service name, and service implementation identifier.

6. The service distribution method based on remote procedure call according to claim 1, characterized in that, In the step of determining whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, and executing a local call or a remote procedure call to realize the service distribution of the business object in the service, the criteria for determining whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service include the name of the implementation class of the service interface of the business object, the name of the microservice where the service implementation is located, and the service root path.

7. A service distribution device based on remote procedure call, characterized in that, include: The object acquisition module is invoked to obtain the general business logic code in the software function code to be invoked. The business logic parts that differ due to different business objects in the software function code to be invoked are replaced by service interfaces. The local proxy acquisition module is used to acquire local proxies for the service interfaces of the software function code to be invoked through a factory class; The service distribution module is used to perform local or remote procedure calls based on whether the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same service, thereby realizing the service distribution of the business object in the service. Specifically, the service distribution module includes the following steps: Determine whether the interface call method and the service implementation are on the same server. When the calling method of the service interface of the software function code to be called and the business implementation in the software function code to be called are in the same server, the local call is executed directly in the server. When the calling method of the service interface of the software function code to be called is on a different server than the business implementation in the software function code to be called, a remote procedure call is executed. Specifically, a remote procedure call is initiated from the initiator of the microservice where the service caller is located to the service implementation proxy class in the receiver of the microservice where the service implementation is located. In the service proxy class of the receiver, the local proxy of the service interface is obtained through the factory class and the interface method is called. The local proxy repeats the process of obtaining the service configuration and determining whether the caller and the service implementation are in the same microservice. At this time, the service caller and the service implementation are definitely in the same microservice, so the call to the interface method is completed through local call. Then the result is returned to the upper local proxy. The upper local proxy returns this result as the result of the remote call to the initiator, and finally the remote procedure call is completed.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a service dispatcher based on remote procedure calls, which, when executed by a processor, implements the steps of the service dispatcher based on remote procedure calls as described in any one of claims 1-6.

9. An electronic device, characterized in that, The system includes a memory and a processor, wherein the memory stores a service dispatcher based on remote procedure calls, and the service dispatcher based on remote procedure calls, when executed by the processor, implements the steps of the service dispatcher based on remote procedure calls as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Program calling method, terminal equipment, and medium

    CN113626225A

  • Logic calling method and device and electronic equipment

    CN113934476A