Method, device and system for notifying service provider entity change in Dubbo framework
By sending change messages containing indication information and service provider entity information in the Dubbo framework, network congestion caused by service provider change notifications is solved, and efficient service updates are achieved.
Patent Information
- Application Number
- CN202010296239.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-15
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-04-15
AI Technical Summary
In the Dubbo framework, when a service provider goes online or goes offline, it needs to notify the service consumers. The existing methods consume a large amount of network resources, resulting in network congestion.
When the service registration center detects a change in the status of the service provider entity, it sends a change message containing the entity information of the service provider entity to reduce the amount of data and avoid network congestion.
By reducing the amount of data of change messages, reducing the consumption of network resources, avoiding network congestion, and ensuring the accuracy and efficiency of service updates.
Smart Images

Figure CN113542319B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a method, device and system for notifying service provider entity changes in a Dubbo framework. Background Art
[0002] The Dubbo framework is an open source framework that provides service registration and discovery functions that can help users quickly build distributed service discovery and remote call systems. The Dubbo framework includes a service registration center, where service providers can register the service information of each service they can provide, their own address, and the port number of the remote call port.
[0003] In this way, the service consumer can subscribe to the service it needs from the service registration center. The service registration center determines the application that includes the subscribed service, and sends the service information of each service included in the application, the address of the service provider that provides the application, and the port number of the remote call port to the service consumer. In this way, the service consumer can initiate a remote call to the service included in the application provided by the service provider based on the service information of each service included in the application, the address of the service provider, and the port number of the remote call port.
[0004] In the process of implementing this application, the inventor found that the prior art has at least the following problems:
[0005] In the process of providing the services included in the application, the service provider may go offline or online. When the service provider goes offline or online, it is necessary to notify the service consumer of the change. However, the current method of notifying the service consumer consumes a lot of network resources, causing network congestion. Summary of the invention
[0006] The present application provides a method, device and system for notifying service provider entity changes in the Dubbo framework to reduce the consumption of network resources and avoid network congestion. The technical solution is as follows:
[0007] In the first aspect, the present application provides a service provider entity change notification method in the Dubbo framework, in which: when the service registration center detects that the state of the service provider entity has changed, it obtains the application identifier of the first application and the service information of each service included in the first application, and the first application is an application provided by the service provider entity. The service registration center determines the service demand entity that has a subscription relationship with the first application based on the service information of each service and the application identifier. The service registration center sends a change message to the service demand entity, and the change message includes indication information, the application identifier, and the entity information of the service provider entity. Since the indication information is used to indicate the changes that have occurred in the service provider entity, the service demand entity can update the entity information corresponding to the subscribed application based on the indication information, and since the change message includes the entity information of the service provider entity whose state has changed, the data volume of the change message can be reduced, thereby reducing the consumption of network resources and avoiding network congestion.
[0008] In one possible implementation, the change is any of the following: In the first case, the service providing entity comes online and the first application is an application that has been cached by the service demand entity. In the second case, the service providing entity comes online, the first application is not an application that has been cached by the service demand entity, and the services include services subscribed by the service demand entity. In the third case, the service providing entity goes offline and the first application is an application that has been cached by the service demand entity. Since three cases of changes in the service providing entity are defined, the changes in the service providing entity can be notified to the service demand entity through indication information. In this way, the service demand entity updates the entity information corresponding to the subscribed application that is cached locally based on the changes indicated by the indication information, thereby avoiding update errors.
[0009] In another possible implementation, when the change situation is the second situation, the change message also includes a service list, and the service list includes service information of each service in the first application. In the second situation, it means that the service demand entity does not cache the first application. The change message also includes a service list, so that the service demand entity can cache the first application.
[0010] In the second aspect, the present application provides a service provider entity change notification method in a Dubbo framework, in which: a service demand entity receives a change message, which is sent by a service registration center when a change is detected in the state of a service provider entity, and the change message includes indication information, an application identifier of a first application, and entity information of a service provider entity, the first application is an application provided by the service provider entity, and the indication information is used to indicate the change of the service provider entity. The service demand entity updates the corresponding relationship between the application identifier, the service list, and the entity list according to the change message, and any record in the corresponding relationship includes the application identifier, the service list, and the entity list of the second application, the second application is an application cached by the service demand entity, the service list includes the service information of each service in the second application, and the entity list includes the entity information of each service provider entity providing the second application. Since the indication information is used to indicate the change of the service provider entity, the service demand entity can update the corresponding relationship based on the indication information to ensure that no update error occurs. Since the change message includes the entity information of the service provider entity whose state has changed, the data volume of the change message can be reduced, thereby reducing the consumption of network resources and avoiding network congestion.
[0011] In a possible implementation, the change is any of the following: In the first case, the service providing entity is online and the first application is an application that has been cached by the service demand entity. In the second case, the service providing entity is online, the first application is not an application that has been cached by the service demand entity, and the services include services subscribed by the service demand entity. In the third case, the service providing entity is offline and the first application is an application that has been cached by the service demand entity. Since three cases of changes in the service providing entity are defined, the changes in the service providing entity can be notified to the service demand entity through indication information, so that the service demand entity updates the corresponding relationship based on the changes indicated by the indication information to avoid update errors.
[0012] In another possible implementation, when the indication information indicates the first situation, the service demand entity adds the entity information of the service providing entity in the entity list corresponding to the application identifier included in the corresponding relationship. When the indication information indicates the third situation, the service demand entity deletes the entity information of the service providing entity in the entity list corresponding to the application identifier included in the corresponding relationship. In this way, the corresponding relationship is updated based on the indication information to avoid the problem of update errors.
[0013] In another possible implementation, when the indication information indicates the second situation, the change message also includes a service list, and the service list includes service information of each service included in the first application. The service demand entity stores the application identifier of the first application, the service list, and the entity information of the service providing entity in the corresponding relationship. In the second situation, it means that the service demand entity does not cache the first application. Since the change message also includes a service list, the application identifier of the first application, the service list, and the entity information of the service providing entity are stored in the corresponding relationship, thereby caching the first application.
[0014] In a third aspect, an embodiment of the present application provides a service provider entity change notification device in a Dubbo framework, which is used to execute the method in the first aspect or any possible implementation of the first aspect. Specifically, the device includes a unit for executing the method in the first aspect or any possible implementation of the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a service provider entity change notification device in a Dubbo framework, which is used to execute the method in the second aspect or any possible implementation of the second aspect. Specifically, the device includes a unit for executing the method in the second aspect or any possible implementation of the second aspect.
[0016] In a fifth aspect, an embodiment of the present application provides a service provider entity change notification device in a Dubbo framework, the device comprising a transceiver, a processor and a memory. The transceiver, the processor and the memory may be connected via a bus system. The memory is used to store programs, instructions or codes, and the processor is used to execute the programs, instructions or codes in the memory to complete the method in the first aspect or any possible implementation of the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a service provider entity change notification device in a Dubbo framework, the device comprising a transceiver, a processor and a memory. The transceiver, the processor and the memory may be connected via a bus system. The memory is used to store programs, instructions or codes, and the processor is used to execute the programs, instructions or codes in the memory to complete the method in the second aspect or any possible implementation of the second aspect.
[0018] In the seventh aspect, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the above-mentioned first aspect, second aspect, any possible implementation method of the first aspect, or any possible implementation method of the second aspect.
[0019] In an eighth aspect, the present application provides an embodiment of a computer-readable storage medium for storing a computer program, wherein the computer program is loaded by a processor to execute instructions of the method of the first aspect, the second aspect, any possible implementation of the first aspect, or any possible implementation of the second aspect.
[0020] In the ninth aspect, the present application provides an embodiment of a service provider entity change notification system in a Dubbo framework, including the device described in the third aspect and the device described in the fourth aspect, or including the device described in the fifth aspect and the device described in the sixth aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a structural diagram of a Dubbo framework provided in an embodiment of the present application;
[0022] Figure 2 This is a flowchart of a subscription service method provided by an embodiment of the present application;
[0023] Figure 3 This is a flow chart of a service provider entity change notification method in a Dubbo framework provided in an embodiment of the present application;
[0024] Figure 4 This is a schematic diagram of the correspondence between an application identifier, a service list, and an entity list provided in an embodiment of the present application;
[0025] Figure 5 This is another flow chart of a service provider entity change notification method in a Dubbo framework provided in an embodiment of the present application;
[0026] Figure 6 This is another schematic diagram of the correspondence between an application identifier, a service list, and an entity list provided in an embodiment of the present application;
[0027] Figure 7 It is a structural diagram of a service providing entity change notification device in a Dubbo framework provided in an embodiment of the present application;
[0028] Figure 8 It is a structural diagram of another service providing entity change notification device in the Dubbo framework provided in an embodiment of the present application;
[0029] Fig. 9 It is a structural diagram of another service providing entity change notification device in the Dubbo framework provided in an embodiment of the present application;
[0030] Fig.10 It is a structural diagram of another service providing entity change notification device in the Dubbo framework provided in an embodiment of the present application;
[0031] Fig.11 It is a structural diagram of a service provider entity change notification system in a Dubbo framework provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0033] See also Figure 1 , the embodiment of the present application provides a Dubbo framework, the Dubbo framework includes:
[0034] A service registration center, at least one service providing entity and at least one service demanding entity, each service providing entity is connected to the service registration center through a network, and each service demanding entity is connected to the service registration center through a network.
[0035] For any one of the at least one service providing entity, the service providing entity runs an application, the application includes at least one service, and can provide the services included in the application. Taking the user management application as an example, the user management application includes services such as querying users, creating users, deleting users, and updating users. The service providing entity runs the user management application and can provide external services such as querying users, creating users, deleting users, and updating users included in the user management application.
[0036] For any application, for the sake of convenience, it is called the first application, and the first application corresponds to a service providing entity set, and the service providing entity set includes at least one service providing entity. Each service providing entity in the service providing entity set provides the services included in the first application.
[0037] For each service provider in the service provider entity set, the service provider can register the services included in the first application that it can provide in the service registration center when going online. In this way, each service provider in the service provider entity set registers the services included in the first application in the service registration center. The service registration center composes the service information of each service included in the first application into a first service list, and the entity information of each service provider in the service provider entity set into a first entity list, and stores the application identifier of the first application, the first service list and the first entity list in the corresponding relationship between the application identifier, the service list and the entity list. Among them, the detailed implementation process of the service provider entity registering the services included in the application in the service registration center will be described later. Figure 4 The illustrated embodiment is described in detail.
[0038] For any one of the at least one service demand entity, a service can be subscribed to in the service registration center. The service registration center determines the application that includes the subscribed service, and sends the application identifier of the application, the service list and entity list corresponding to the application to the service demand entity. The service list corresponding to the application includes service information of each service in the application, and the entity list corresponding to the application includes entity information of each service provider entity that runs the application. The service demand entity receives the application identifier of the application, the service list and entity list corresponding to the application, and can select the entity information of the service provider entity used to run the application from the entity list, and call any service included in the application based on the entity information and the service list. The detailed implementation process of the service demand entity subscribing to the service in the service registration center will be described later. Figure 2 The illustrated embodiment is described in detail.
[0039] For any service provider in the service provider entity set, the status of the service provider entity may change, that is, the service provider entity may go online or offline. The so-called service provider entity going online means that the service provider entity establishes a network connection with the service registration center. At this time, the service provider entity can run the application and provide the services included in the application to the outside world. The so-called service provider entity going offline means that the network connection between the service provider entity and the service registration center is disconnected. At this time, the service provider entity stops providing the services included in the application to the outside world. When the status of the service provider entity changes, the service registration center needs to promptly notify the service demand entity that has a subscription relationship with the application, so that the service demand entity stops calling the services included in the application from the service provider entity. Among them, the detailed implementation process of the service registration center notifying the service demand entity when the status of the service provider entity changes will be described later. Figure 4 Or the embodiment shown in 6 is described in detail.
[0040] Optionally, the service providing entity may be referred to as a service provider, which may be a server, a virtual machine, or a container, etc. The service demanding entity may be referred to as a service consumer, which may be a server, a virtual machine, a client, a container, or a terminal device, etc.
[0041] Optionally, the service information of a service includes the group in which the service is located, the service name and version. The service information of the service may also include information such as the method provided by the service.
[0042] Optionally, the entity information of the service providing entity includes the address of the service providing entity and the port number of the remote call port, where the address is the Internet protocol (IP) address of the service providing entity, etc.
[0043] See also Figure 2, the present application embodiment provides a method for subscribing to a service, which can be applied to Figure 1 The Dubbo framework shown in FIG. 1 includes:
[0044] Step 101: a service demand entity sends a subscription request message to a service registration center. The subscription request message includes a subscription condition, and the subscription condition includes service information of at least one service to be subscribed.
[0045] Optionally, the subscription conditions include the group, service name and version of each service to be subscribed.
[0046] The service demand entity establishes a network connection with the service registration center, and sends a subscription request message to the service registration center through the network connection, where the subscription request message includes subscription conditions.
[0047] For example, the service to be subscribed is a user query service, and the subscription condition includes the group of the service to be subscribed being "Group 1", the service name being "Query User", and the version being "V1.0". The service demand entity receives the subscription condition and sends a subscription request message including the subscription condition to the service registration center.
[0048] Step 102: The service registration center receives the subscription request message, and obtains the application identifier of the second application that meets the subscription condition, the second service list and the second entity list corresponding to the second application from the registered applications.
[0049] The service registration center stores the correspondence between the application identifier, the service list and the entity list. Any record in the correspondence includes the application identifier of the second application, the second service list and the second entity list. The second application is an application registered in the service registration center. The second service list includes service information of each service in the second application. The second entity list includes entity information of each service providing entity running the second application.
[0050] For example, see Figure 3 The corresponding relationship between the application identifier, service list and entity list shown in the figure stores a record including the application identifier of the user management application, the service list and entity list corresponding to the user management application. The user management application includes four services: query user, create user, delete user and update user. The service providing entity running the user management application includes a first providing entity and a second providing entity.
[0051] exist Figure 3In the corresponding relationship shown, the application identifier of the user management application is App1, and the service list corresponding to the user management application includes the service information of querying users, creating users, deleting users, and updating users of the user management application. Among them, the service information of querying users includes "Group 1" of querying users, service name "Query User" and version "V1.0", the service information of creating users includes "Group 2" of creating users, service name "Create User" and version "V1.0", the service information of deleting users includes "Group 1" of deleting users, service name "Delete User" and version "V2.0", and the service information of updating users includes "Group 3" of updating users, service name "Update User" and version "V2.0". The entity list corresponding to the user management application includes the entity information of the first service provider entity and the entity information of the second service provider entity, wherein the entity information of the first service provider entity includes the address "IP1" of the first service provider entity and the port number "Port1" of the remote call port, and the entity information of the second service provider entity includes the address "IP2" of the second service provider entity and the port number "Port1" of the remote call port.
[0052] In this step, the service registration center searches for a service list including the subscription condition in the service list of each application in the correspondence between the application identifier, the service list, and the entity list, and obtains the second service list. From the correspondence between the application identifier, the service list, and the entity list, the application identifier corresponding to the second service list is obtained as the application identifier of the second application, and the entity list corresponding to the second service list is obtained as the second entity list corresponding to the second application.
[0053] For example, the service registration center receives a subscription request message, in which the subscription conditions include the group "Group 1" of the service to be subscribed, the service name "Query User" and the version "V1.0". Figure 3 In the corresponding relationship between the application identifier, service list and entity list shown in FIG. 1 , the service list of each application including the subscription condition is searched, and the service list is the service list corresponding to the user management application. According to the service list, from Figure 3 In the correspondence between the application identifier, service list and entity list shown, the application identifier "App1" and the entity example table of the user management application are obtained.
[0054] Step 103: The service registration center sends a subscription response message to the service demand entity. The subscription response message includes an application identifier of the second application, a second service list, and a second entity list.
[0055] Step 104: the service registration center stores the address of the service demand entity, the application list and the subscription condition in correspondence between the address of the service demand entity, the application list and the subscription condition, wherein the application list includes the application identifier of the second application satisfying the subscription condition.
[0056] Optionally, the correspondence between the address of the service demand entity, the application list, and the subscription condition includes a correspondence between the address of the service demand entity and the application list, and a correspondence between the address of the service demand entity and the subscription condition.
[0057] In this step, the service registration center stores the address of the service demand entity and the application list in the corresponding relationship between the address of the service demand entity and the application list, and stores the address of the service demand entity and the subscription condition in the corresponding relationship between the address of the service demand entity and the subscription condition.
[0058] Step 105: The service demand entity receives the subscription response message, and stores the application identifier of the second application, the second service list, and the second entity list in a corresponding relationship between the application identifier, the service list, and the entity list.
[0059] For each other service demand entity in the Dubbo framework, the application service is subscribed in the service registration center according to the above operations 201 to 206.
[0060] See also Figure 4 , the present application embodiment provides a service provider entity change notification method in the Dubbo framework, which is applied to Figure 1 The Dubbo framework provided by the illustrated embodiment. In the method, the change operation of the service providing entity is going online. When the service providing entity goes online, it registers a first application in the service registration center. The first application is an application running on the service providing entity. The service registration center notifies the service demand entity that has a subscription relationship with the first application. The method includes:
[0061] Step 201: The service provider entity sends a registration request message to a service registration center. The registration request message includes a first service list and entity information of the service provider entity. The first service list includes service information of each service in a first application. The first application is an application run by the service provider entity.
[0062] The service information of a service includes information such as the group to which the service belongs, the service name of the service, and the version of the service. Optionally, the service information of the service also includes information such as the method provided by the service. The entity information of the service provider includes the address of the service provider and the port number of the remote call port.
[0063] In this step, after the service provider entity is started, it establishes a network connection with the service registration center and sends a registration request message to the service registration center through the network connection. When the service provider entity establishes a network connection with the service registration center, it indicates that the service provider entity is online.
[0064] For example, it is assumed that the third service provider of the user management application sends a registration request message to the registration center, and the registration request message includes the first service list and the entity information of the third service provider, and the first service list includes querying the user's service information, creating the user's service information, deleting the user's service information, and updating the user's service information. The entity information of the third service provider includes the address "IP3" of the third service entity and the port number "Port2" of the remote call port.
[0065] Step 202: The service registration center receives the registration request message and determines whether the first application is an application registered in the service registration center. If yes, execute step 203; if no, execute step 204.
[0066] The service registration center stores the correspondence between the application identifier, the service list and the entity list. Any record in the correspondence includes the application identifier of the second application, the second service list and the second entity list. The second application is an application registered in the service registration center. The second service list includes service information of each service in the second application. The second entity list includes entity information of each service providing entity that provides the second application.
[0067] In this step, the service registration center receives the registration request message, and queries whether the correspondence between the application identifier, service list, and entity list includes the first service list carried in the registration request message. If the query finds that the correspondence includes the first service list, it indicates that the first application has been registered in the service registration center; if the query finds that the correspondence does not include the first service list, it indicates that the first application has not been registered in the service registration center.
[0068] It should be noted that: the first application corresponds to a service provider set, and the service provider entity is one of the service provider set. If the query finds that the corresponding relationship includes the first service list, it means that before executing this step, other service providers in the service provider set have requested the service registration center to register the first application.
[0069] Step 203: the service registration center adds the entity information of the service providing entity to the entity list corresponding to the first application included in the corresponding relationship, and executes step 205.
[0070] The service registration center queries the correspondence between the application identifier, service list and entity list, including the first service list corresponding to the first application, indicating that the first application has been registered in the service registration center. Therefore, the application identifier of the first application corresponding to the first service list and the entity list corresponding to the first application can be queried from the correspondence, and the entity information of the service provider entity can be added to the entity list corresponding to the first application.
[0071] For example, the service registration center receives a registration request message sent by a third service providing entity, and searches for a first service list included in the registration request message. Figure 3 The corresponding relationship among the application identifier, service list and entity list shown in FIG. 1 is obtained, and the corresponding relationship includes the first service list, thereby determining that the user management application is an application registered in the service registration center, and adding the entity information of the third service providing entity to the entity list corresponding to the user management application, and obtaining the following: Figure 5 The correspondence between the application identifier, service list and entity list is shown.
[0072] Step 204: the service registration center allocates an application identifier of the first application, and stores the application identifier of the first application, the first service list, and the first entity list in correspondence between the application identifier, the service list, and the entity list, wherein the first entity list includes entity information of the service entity.
[0073] After executing this step, when other service providing entities running the first application request to register the first application in the service registration center, the service registration center only needs to add the entity information of the other application to the first entity list to register the first application.
[0074] Step 205: The service registration center determines a service demand entity that has a subscription relationship with the first application, and determines changes that occur to the service providing entity for the service demand entity.
[0075] This step can be implemented in a variety of ways. The following is an implementation example. In this implementation example, a record is read from the correspondence between the address, application list and subscription conditions of a service demand entity. The record includes the address, application list and subscription conditions of a service demand entity. The applications corresponding to each application identifier in the application list have been cached in the service demand entity. The application list includes the application identifier of the first application, and it is determined that the service demand entity has a subscription relationship with the first application, and it is determined that the service demand entity has cached the first application. For the service demand entity, it is determined that the change that has occurred in the service providing entity is the first case. The first case is that the service providing entity is online and the first application is an application that has been cached by the service demand entity.
[0076] If the application identifier of the first application is not included in the application list, it is determined that the service demand entity has not cached the first application, and whether the services included in the first application include the services subscribed by the service demand entity is further determined based on the subscription condition and the first service list. If they are included, it is determined that the service demand entity has a subscription relationship with the first application. For the service demand entity, it is determined that the change that has occurred in the service providing entity is the second case, where the service providing entity is online, the first application is not an application that has been cached by the service demand entity, and the services included in the first application include the services subscribed by the service demand entity. If they are not included, it is determined that the service demand entity has no subscription relationship with the first application.
[0077] The service registration center reads the next record from the correspondence between the address, application list and subscription conditions, and then executes the above process again until the above process is executed for each record in the correspondence between the address, application list and subscription conditions, thereby obtaining each service demand entity that has a subscription relationship with the first application, and for each service demand entity, determining the changes that have occurred to the service providing entity.
[0078] Step 206: The service registration center sends a change message to the service demand entity. The change message includes indication information, an application identifier of the first application, and entity information of the service providing entity. The indication information is used to indicate changes that have occurred to the service providing entity for the service demand entity.
[0079] The indication information is used to indicate the first situation or the second situation. Wherein, when the indication information is used to indicate the second situation, the change message also includes the first service list.
[0080] If the service registration center determines that there are multiple service demand entities that have a subscription relationship with the first application, a change message is sent to each service demand entity.
[0081] Step 207: The service demand entity receives the change message, and updates the correspondence between the application identifier, the service list, and the entity list according to the change message.
[0082] In this step, the service demand entity receives the change message, which includes indication information, an application identifier of the first application, and entity information of the service providing entity.
[0083] When the indication information indicates the first situation, the service demand entity searches for the entity list corresponding to the first application from the correspondence between the application identification, the service list and the entity list according to the application identification of the first application, and adds the entity information of the service providing entity to the entity list corresponding to the first application. When the indication information indicates the second situation, the change message also includes the first service list, and the service demand entity stores the application identification of the first application, the first service list and the entity information of the service providing entity in the correspondence between the application identification, the service list and the entity list.
[0084] In an embodiment of the present application, when a service provider entity goes online and registers a first application in a service registration center, the service registration center determines a service demand entity that has a subscription relationship with the first application, and determines the changes that have occurred to the service provider entity with respect to the service demand entity, and then sends a change message to the service demand entity, the change message including indication information for indicating the change, entity information of the service provider entity, and an application identifier of the first application. Since the change message includes the entity information of the service provider entity and does not include other redundant information, the data volume of the change message is reduced, thereby reducing the network resources that need to be consumed to notify the service demand entity, avoiding network congestion, and avoiding affecting the availability of the service registration center. Among them, there may be multiple service demand entities that have a subscription relationship with the first application. Since the change message sent to each service demand entity does not include other redundant information, when sending a change message to each service demand entity, the consumption of network resources will be greatly reduced.
[0085] See also Figure 6 , the present application embodiment provides a service provider entity change notification method in the Dubbo framework, which is applied to Figure 1 The Dubbo framework provided by the illustrated embodiment. In the method, the change operation of the service providing entity is offline, and the service registration center notifies the service demand entity that has a subscription relationship with the first application, and the first application is the application running on the service providing entity. The method includes:
[0086] Step 301: When the service registration center detects that the service providing entity is offline, it obtains the application identifier of the first application.
[0087] After the service provider entity goes online, the service registration center detects the service provider entity. Optionally, the service registration center can use heartbeat information for detection. The detection process is: the service registration center periodically sends heartbeat information to the service provider entity. If the service provider entity is online, the service provider entity sends a heartbeat response to the service registration center after receiving the heartbeat information; if the service provider entity is offline, the service provider entity will not receive the heartbeat information and will not send a heartbeat response to the service registration center. When the service registration center receives the heartbeat response, it determines that the service provider entity is online. If it does not receive the heartbeat response, it determines that the service provider entity is offline.
[0088] When the service registration center detects that the service provider entity is offline, it obtains the address of the service provider entity, obtains the target entity list including the address of the service provider entity from the correspondence between the application identifier, service list and entity list, and obtains the application identifier corresponding to the target entity list as the first application identifier.
[0089] Optionally, the service registration center also deletes the entity information of the service providing entity from the target entity list.
[0090] Step 302: The service registration entity determines a service demand entity that has a subscription relationship with the first application, and determines changes that occur to the service providing entity for the service demand entity.
[0091] This step can be implemented in a variety of ways. The following is an implementation example. In this implementation example, a record is read from the correspondence between the address, application list and subscription conditions of a service demand entity. The record includes the address, application list and subscription conditions of a service demand entity. The applications corresponding to each application identifier in the application list have been cached in the service demand entity. The application identifier of the first application is included in the application list, and it is determined that the service demand entity has a subscription relationship with the first application, and it is determined that the service demand entity has cached the first application. For the service demand entity, it is determined that the change that has occurred in the service providing entity is the third case, and the third case is that the service providing entity is offline and the first application is an application that has been cached by the service demand entity. The application identifier of the first application is not included in the application list, and it is determined that the service demand entity has no subscription relationship with the first application.
[0092] The service registration center reads the next record from the correspondence between the address, application list and subscription conditions, and then executes the above process again until the above process is executed for each record in the correspondence between the address, application list and subscription conditions of the service demand entity, thereby obtaining each service demand entity that has a subscription relationship with the first application, and for each service demand entity, the changes that have occurred to the service providing entity.
[0093] Step 303: The service registration center sends a change message to the service demand entity. The change message includes indication information, an application identifier of the first application, and entity information of the service providing entity. The indication information is used to indicate changes that have occurred to the service providing entity for the service demand entity.
[0094] The indication information is used to indicate the third situation. If the service registration center determines that there are multiple service demand entities that have a subscription relationship with the first application, a change message is sent to each service demand entity.
[0095] Step 304: The service demand entity receives the change message, and updates the correspondence between the application identifier, the service list, and the entity list according to the change message.
[0096] In this step, the service demand entity receives the change message, which includes indication information, an application identifier of the first application, and entity information of the service providing entity.
[0097] When the indication information indicates the third situation, the service demand entity searches for the entity list corresponding to the first application from the correspondence between the application identifier, the service list and the entity list according to the application identifier of the first application, and deletes the entity information of the service providing entity included in the change message from the searched entity list.
[0098] In an embodiment of the present application, when a service providing entity goes offline, a service registration center determines a service demand entity that has a subscription relationship with a first application, and determines changes that have occurred to the service providing entity with respect to the service demand entity, and then sends a change message to the service demand entity, the change message including indication information for indicating the change, entity information of the service providing entity, and an application identifier of the first application. Since the change message includes the entity information of the service providing entity and does not include other redundant information, the data volume of the change message is reduced, thereby reducing the network resources that need to be consumed to notify the service demand entity, avoiding network congestion, and avoiding affecting the availability of the service registration center. Among them, there may be multiple service demand entities that have a subscription relationship with the first application. Since the change message sent to each service demand entity does not include other redundant information, when sending a change message to each service demand entity, the consumption of network resources will be greatly reduced.
[0099] See also Figure 7 The embodiment of the present application provides a service provider entity change notification device 400 in the Dubbo framework. The device 400 can be deployed in the service registration center provided in any of the above embodiments, including:
[0100] The processing unit 401 is configured to, when detecting that a state of a service providing entity has changed, obtain an application identifier of a first application and service information of each service included in the first application, where the first application is an application provided by the service providing entity; and determine a service demand entity that has a subscription relationship with the first application according to the service information of each service included in the first application and the application identifier of the first application;
[0101] The sending unit 402 is used to send a change message to the service demand entity, where the change message includes indication information, an application identifier of the first application and entity information of the service providing entity, and the indication information is used to indicate changes in the service providing entity.
[0102] Optionally, the change is any of the following:
[0103] In the first case, the service providing entity is online and the first application is an application that has been cached by the service demanding entity;
[0104] In the second case, the service providing entity goes online, the first application is not an application that has been cached by the service demanding entity, and each service in the first application includes a service subscribed by the service demanding entity;
[0105] In the third case, the service providing entity is offline and the first application is an application that has been cached by the service demanding entity.
[0106] Optionally, when the change situation is the second situation, the change message also includes a service list, and the service list includes service information of each service in the first application.
[0107] In an embodiment of the present application, when the processing unit detects that the state of the service providing entity has changed, the application identifier of the first application and the service information of each service included in the first application are obtained, and the service demand entity that has a subscription relationship with the first application is determined based on the service information of each service and the application identifier. The sending unit sends a change message to the service demand entity, and the change message includes indication information, the application identifier, and entity information of the service providing entity. Since the indication information is used to indicate the changes that have occurred in the service providing entity, the service demand entity can update the entity information corresponding to the subscribed application based on the indication information, and since the change message includes the entity information of the service providing entity whose state has changed, the data volume of the change message can be reduced, thereby reducing the consumption of network resources and avoiding network congestion.
[0108] See also Figure 8 The embodiment of the present application provides a service providing entity change notification device 500 in the Dubbo framework. The device 500 can be deployed in the service demand entity provided in any of the above embodiments, including:
[0109] A receiving unit 501 is used to receive a change message, which is sent by the service registration center when detecting that the state of the service providing entity has changed. The change message includes indication information, an application identifier of the first application and entity information of the service providing entity. The first application is an application provided by the service providing entity, and the indication information is used to indicate the change of the service providing entity;
[0110] The processing unit 502 is used to update the correspondence between the application identifier, the service list and the entity list according to the change message, wherein any record in the correspondence includes the application identifier, the service list and the entity list of the second application, the second application is an application cached by the device 500, the service list includes service information of each service in the second application, and the entity list includes entity information of each service providing entity that provides the second application.
[0111] Optionally, the change is any of the following:
[0112] In the first case, the service providing entity is online and the first application is an application cached by the device 500;
[0113] In the second case, the service providing entity is online, the first application is not an application cached by the device 500, and each service in the first application includes a service subscribed by the device 500;
[0114] In a third case, the service providing entity is offline and the first application is an application that has been cached by the device 500 .
[0115] Optionally, the processing unit 502 is configured to:
[0116] When the indication information indicates the first case, in the entity list corresponding to the application identifier included in the corresponding relationship, the entity information of the service providing entity is added;
[0117] When the indication information indicates the third situation, the entity information of the service providing entity is deleted from the entity list corresponding to the application identifier included in the corresponding relationship.
[0118] Optionally, when the indication information indicates the second situation, the change message further includes a service list, and the service list includes service information of each service included in the first application;
[0119] The processing unit 502 is configured to store the application identifier of the first application, the service list, and the entity information of the service providing entity in the corresponding relationship.
[0120] In an embodiment of the present application, a receiving unit receives a change message, which includes indication information, an application identifier of a first application, and entity information of a service providing entity, and the indication information is used to indicate changes that have occurred in the service providing entity. The processing unit updates the correspondence between the application identifier, the service list, and the entity list according to the change message. Since the indication information is used to indicate changes that have occurred in the service providing entity, the processing unit can update the correspondence based on the indication information to ensure that no update errors occur. Since the change message includes the entity information of the service providing entity whose status has changed, the data volume of the change message can be reduced, thereby reducing the consumption of network resources and avoiding network congestion.
[0121] See also Fig. 9 , an embodiment of the present application provides a schematic diagram of a service provider entity change notification device 600 in a Dubbo framework. The device 600 may be a service registration center in any of the above embodiments. The device 600 includes at least one processor 601, a bus system 602, a memory 603, and at least one transceiver 604.
[0122] The device 600 is a hardware structure device that can be used to implement Figure 7 The functional modules in the device 400 are as follows. For example, those skilled in the art may think of Figure 7 The processing unit 401 in the device 400 shown can be implemented by the at least one processor 601 calling the code in the memory 603. Figure 7 The sending unit 402 in the device 400 shown may be implemented by the transceiver 604 .
[0123] Optionally, the device 600 can also be used to implement the functions of the network device (service registration center) in any of the above embodiments.
[0124] Optionally, the processor 601 may be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0125] The bus system 602 may include a path for transmitting information between the components.
[0126] The transceiver 604 is used to communicate with other devices or communication networks.
[0127] The memory 603 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a bus. The memory may also be integrated with the processor.
[0128] The memory 603 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 601. The processor 601 is used to execute the application code stored in the memory 603, so as to realize the functions in the method of the present patent.
[0129] In a specific implementation, as an embodiment, the processor 601 may include one or more CPUs, such as Fig. 9 CPU0 and CPU1 in.
[0130] In a specific implementation, as an embodiment, the device 600 may include multiple processors, such as Fig. 9 601 and processor 607 in FIG. Each of these processors may be a single-CPU processor or a multi-CPU processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0131] See also Fig.10 , an embodiment of the present application provides a schematic diagram of a service provider entity change notification device 700 in a Dubbo framework. The device 700 may be a service registration center in any of the above embodiments. The device 700 includes at least one processor 701, a bus system 702, a memory 703, and at least one transceiver 704.
[0132] The device 700 is a hardware structure device that can be used to implement Figure 8The functional modules in the device 500 are as follows. For example, those skilled in the art may think of Figure 8 The processing unit 502 in the device 500 shown can be implemented by the at least one processor 701 calling the code in the memory 703. Figure 8 The receiving unit 501 in the device 500 shown may be implemented by the transceiver 704 .
[0133] Optionally, the device 700 may also be used to implement the functions of the network device (service demand entity) in any of the above embodiments.
[0134] Optionally, the processor 701 may be a general-purpose central processing unit (CPU), a network processor (NP), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0135] The bus system 702 may include a path for transmitting information between the components.
[0136] The transceiver 704 is used to communicate with other devices or communication networks.
[0137] The memory 703 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via a bus. The memory may also be integrated with the processor.
[0138] The memory 703 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 701. The processor 701 is used to execute the application code stored in the memory 703, thereby realizing the functions in the method of the present patent.
[0139] In a specific implementation, as an embodiment, the processor 701 may include one or more CPUs, such as Fig.10 CPU0 and CPU1 in.
[0140] In a specific implementation, as an embodiment, the device 700 may include multiple processors, such as Fig.10 701 and processor 707 in the embodiment of the present invention. Each of these processors may be a single-CPU processor or a multi-CPU processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0141] See also Fig.11 The embodiment of the present application provides a service provider entity change notification system 800 in the Dubbo framework, and the system 800 includes: Figure 7 The device 400 and Figure 8 The device 500, or the system 800 includes: Fig. 9 The device 600 and Fig.10 The device 700.
[0142] Among them, Figure 7 The device 400 and Fig. 9 The device 600 can serve the registration center 801, such as Figure 8 The device 500 and Fig.10 The device 700 may be a service demand entity 802 .
[0143] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0144] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A service provider entity change notification method in the Dubbo framework, characterized in that: The method comprises: When the service registration center detects that the state of the service providing entity has changed, the service registration center obtains the application identifier of the first application and the service information of each service included in the first application, wherein the service information includes the group to which the service belongs, the service name and the version, and the first application is an application provided by the service providing entity; The service registration center determines, according to the service information of each service and the application identifier, a service demand entity that has a subscription relationship with the first application; The service registration center sends a change message to the service demand entity, and the change message includes indication information, the application identifier and entity information of the service provider entity. The entity information includes the address of the service provider entity and the port number of the remote call port. The indication information is used to indicate the changes that have occurred to the service provider entity.
2. The method according to claim 1, characterized in that The change is any of the following: In the first case, the service providing entity is online and the first application is an application that has been cached by the service demanding entity; In the second case, the service providing entity is online, the first application is not an application cached by the service demanding entity, and the services include services subscribed by the service demanding entity; In a third case, the service providing entity is offline and the first application is an application that has been cached by the service demanding entity.
3. The method according to claim 2, characterized in that When the change situation is the second situation, the change message further includes a service list, and the service list includes service information of each service in the first application.
4. A service provider entity change notification method in the Dubbo framework, characterized in that: The method comprises: The service demand entity receives a change message, wherein the change message is sent by the service registration center when detecting that the state of the service providing entity has changed, and the change message includes indication information, an application identifier of the first application, and entity information of the service providing entity, wherein the entity information includes an address of the service providing entity and a port number of a remote call port, the first application is an application provided by the service providing entity, and the indication information is used to indicate the change of the service providing entity; The service demand entity updates the correspondence between the application identifier, service list and entity list according to the change message, wherein any record in the correspondence includes the application identifier, service list and entity list of the second application, the second application is an application cached by the service demand entity, the service list includes service information of each service in the second application, the service information of the service includes the group to which the service belongs, the service name and version, and the entity list includes entity information of each service providing entity that provides the second application.
5. The method according to claim 4, characterized in that The change is any of the following: In the first case, the service providing entity is online and the first application is an application that has been cached by the service demanding entity; In the second case, the service providing entity is online, the first application is not an application cached by the service demanding entity, and the services include services subscribed by the service demanding entity; In a third case, the service providing entity is offline and the first application is an application that has been cached by the service demanding entity.
6. The method according to claim 5, characterized in that The service demand entity updates the correspondence between the application identifier, the service list and the entity list according to the change message, including: When the indication information indicates the first situation, the service demand entity adds the entity information of the service providing entity in the entity list corresponding to the application identifier included in the corresponding relationship; When the indication information indicates the third situation, the service demanding entity deletes the entity information of the service providing entity in the entity list corresponding to the application identifier included in the corresponding relationship.
7. The method according to claim 5, characterized in that When the indication information indicates the second situation, the change message further includes a service list, and the service list includes service information of each service included in the first application; The service demand entity updates the correspondence between the application identifier, the service list and the entity list according to the change message, including: The service demand entity stores the application identifier of the first application, the service list, and the entity information of the service providing entity in the corresponding relationship.
8. A service provider entity change notification device in a Dubbo framework, characterized in that: The device comprises: a processing unit, configured to, when detecting that a state of a service providing entity has changed, obtain an application identifier of a first application and service information of each service included in the first application, wherein the service information includes a group to which the service belongs, a service name, and a version, and the first application is an application provided by the service providing entity; and determine a service demand entity that has a subscription relationship with the first application according to the service information of each service and the application identifier; A sending unit is used to send a change message to the service demand entity, wherein the change message includes indication information, the application identifier and entity information of the service providing entity, the entity information includes the address of the service providing entity and the port number of the remote call port, and the indication information is used to indicate the changes that have occurred to the service providing entity.
9. The device according to claim 8, characterized in that The change is any of the following: In the first case, the service providing entity is online and the first application is an application that has been cached by the service demanding entity; In the second case, the service providing entity is online, the first application is not an application cached by the service demanding entity, and the services include services subscribed by the service demanding entity; In a third case, the service providing entity is offline and the first application is an application that has been cached by the service demanding entity.
10. The device according to claim 9, characterized in that When the change situation is the second situation, the change message further includes a service list, and the service list includes service information of each service in the first application.
11. A service provider entity change notification device in a Dubbo framework, characterized in that: The device comprises: A receiving unit, configured to receive a change message, wherein the change message is sent by the service registration center when detecting that the state of a service providing entity has changed, the change message includes indication information, an application identifier of a first application, and entity information of the service providing entity, the entity information includes an address of the service providing entity and a port number of a remote call port, the first application is an application provided by the service providing entity, and the indication information is used to indicate a change of the service providing entity; A processing unit, used to update the correspondence between the application identifier, service list and entity list according to the change message, wherein any record in the correspondence includes the application identifier, service list and entity list of the second application, the second application is an application cached by the device, the service list includes service information of each service in the second application, the service information of the service includes the group to which the service belongs, the service name and version, and the entity list includes entity information of each service providing entity that provides the second application.
12. The device according to claim 11, characterized in that The change is any of the following: In the first case, the service providing entity is online and the first application is an application cached by the device; In the second case, the service providing entity is online, the first application is not an application cached by the device, and the services include services subscribed by the device; In a third case, the service providing entity is offline and the first application is an application cached by the device.
13. The device according to claim 12, characterized in that The processing unit is used for: When the indication information indicates the first situation, adding the entity information of the service providing entity in the entity list corresponding to the application identifier included in the corresponding relationship; When the indication information indicates the third situation, the entity information of the service providing entity is deleted from the entity list corresponding to the application identifier included in the corresponding relationship.
14. The device according to claim 12, characterized in that When the indication information indicates the second situation, the change message further includes a service list, and the service list includes service information of each service included in the first application; The processing unit is used to store the application identifier of the first application, the service list and the entity information of the service providing entity in the corresponding relationship.
15. A service provider entity change notification system in the Dubbo framework, characterized in that: The system comprises the device according to any one of claims 8 to 10 and the device according to any one of claims 11 to 14.
16. A service provider entity change notification device in a Dubbo framework, characterized in that: The device includes a memory, a processor, and a computer program stored in the memory. When the processor executes the computer program, the device implements the method according to any one of claims 1 to 3 or the method according to any one of claims 4 to 7.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 or the method according to any one of claims 4 to 7 is implemented.
18. A computer program product, characterized in that The computer program product comprises a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the method according to any one of claims 1 to 3 or the method according to any one of claims 4 to 7.
Citation Information
Patent Citations
Service discovering method based on cooperation of registration center and caching mechanism
CN105933444A