A method and system for dynamically loading plug-ins and starting and stopping ports based on a micro-service gateway
By using a dynamic class manager and memory-mapped tables to manage microservice gateway plugins and ports, the problem of dynamic loading and starting/stopping in existing technologies is solved, achieving high availability and system continuity, and improving system stability and manageability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 北京领雁科技股份有限公司
- Filing Date
- 2025-12-24
- Publication Date
- 2026-07-03
AI Technical Summary
Existing microservice gateways cannot dynamically load dependent plugin packages during operation, cannot dynamically start or stop non-native gateway service ports, and lack the ability to update the gateway's running memory without downtime, affecting high availability and continuity.
It loads public and private dependency plugin packages through a dynamic class manager, dynamically manages transmission ports, supports enabling, disabling, restarting, and parameter refreshing operations without restarting the gateway, and utilizes memory mapping tables and distributed caching to achieve real-time monitoring and configuration.
It enables dynamic loading of plugins and start/stop ports without restarting the gateway, ensuring high availability and system continuity, supporting millisecond-level effects, and enhancing system stability and manageability.
Smart Images

Figure CN121691019B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of microservice gateway technology, and in particular to a method and system for dynamically loading plugins and starting / stopping ports based on a microservice gateway. Background Technology
[0002] With the widespread adoption of microservice architecture, microservice gateways, as the system's traffic entry point, undertake crucial functions such as request routing, protocol conversion, and security protection. In industries like finance and telecommunications, microservice gateways not only need to support the standard HTTP protocol but also the access and processing of various non-HTTP protocols. Currently, microservice gateway technology has made some progress, but some technical challenges remain regarding dynamic plugin loading and port management.
[0003] In the prior art, CN116192933B discloses a method and system for dynamically extending non-HTTP protocols based on a microservice gateway. This method obtains the local address, port, and protocol to be listened to when the microservice gateway starts, calls the corresponding service listener based on the protocol to set the address parameters and start service listening, and after receiving packets, performs conversion processing and forwards them to subsequent application microservices. This technology enables the transmission of non-JSON packets via non-HTTP protocols in a microservice architecture; however, this solution requires all ports and protocols to be listened to to be determined at gateway startup, and cannot be dynamically adjusted during runtime.
[0004] CN115102849A proposes a method and apparatus for dynamically loading and configuring service gateway plugins. Plugins are configured and their parameters are validated through a management side page. When the gateway detects a plugin change, it updates the current plugin configuration in real time, caches the plugin information locally, and maps the plugin to its URL. This method achieves dynamic plugin configuration and reduces program downtime. However, it primarily focuses on plugin management for the HTTP protocol, offering limited support for port management and dynamic parameter adjustment for non-HTTP protocols.
[0005] CN110572405A describes a real-time microservice architecture, including a front-end service module, a back-end service module, and a deployment service module. It sends raw data and protocol parsing service requests to the back-end service module via an API gateway. This architecture encapsulates each protocol conversion function as a real-time microservice, providing general and common protocol conversion services, but it does not address the issue of dynamically adjusting protocol parsing parameters.
[0006] CN114979309B proposes a method to support on-the-fly access and processing of networked target data, including dynamic protocol compilation and protocol stack management, packet header detection and protocol matching, etc. This method defines a set of universal interfaces that provide common support for parsing different protocols, standardizing the protocol parsing process, input, and output; however, it lacks a dynamic management mechanism for gateway ports.
[0007] CN119232808A discloses a multi-protocol IoT system and a development method for a multi-protocol IoT soft gateway. This system uses a protocol parsing plugin to transmit device messages of different protocols to the soft gateway layer, and then transmits them to the cloud IoT platform layer via the MQTT protocol. This method solves the compatibility problem of devices with different communication protocols accessing the IoT platform, but it does not provide fine-grained management and visual monitoring capabilities at the port level.
[0008] However, existing technologies have the following shortcomings: First, most microservice gateways do not support dynamically loading dependency plugin packages during runtime. Modifying dependency plugin packages requires restarting the gateway service, causing request processing interruptions and impacting scenarios with strict high availability requirements. Second, existing gateways generally do not support dynamically starting or stopping non-native gateway business ports. Starting or stopping ports often requires restarting the entire gateway, affecting the continuous operation of all services. Finally, existing technologies lack the ability to update the gateway's runtime memory without downtime, making it difficult to monitor and adjust the gateway's operating status in real time. These problems are particularly prominent in scenarios with high system continuity requirements, such as financial transactions and real-time communication, urgently requiring a technical solution that can achieve dynamic plugin loading and fine-grained port management without service interruption. Summary of the Invention
[0009] To address the technical issues of existing native microservice gateways not supporting dynamic loading of dependency plugin packages, not supporting dynamic start / stop of non-native gateway business ports, and lacking the ability to update gateway runtime memory without downtime, this application provides a method and system for dynamically loading plugins and starting / stopping ports based on a microservice gateway, enabling the gateway to dynamically load plugins and start / stop ports without restarting.
[0010] According to a first aspect of the present invention, a method for dynamically loading plugins and starting / stopping ports based on a microservice gateway is provided, comprising: loading public dependency plugin packages and private dependency plugin packages through a dynamic loading class manager when the gateway starts; after the dependency plugin packages are loaded, calling a method to start listening on the transmission port, traversing the address information bound to the gateway to load information and start listening; responding to a query command for deployed gateways, querying deployed gateways through a registry center interface on the online gateway management interface and displaying gateway running instances; responding to a command to view the address information of a gateway running instance, querying the address information of all deployed gateways in the database, comparing it with the addresses loaded by the protocol in the memory mapping table, and returning address information including address status. In response to address information management commands, without restarting the gateway, it performs enable, disable, restart, or parameter refresh operations on a single address. Specifically: the enable operation includes calling the enable transmission method through the transmission manager and locking the enable operation; the disable operation includes retrieving the transmission proxy object from the memory-mapped table based on the address's English name and locking the disable operation; the restart operation includes calling the disable and enable methods sequentially; the parameter refresh operation includes retrieving the latest address parameter information from the distributed cache, retrieving the transmission proxy object based on the address, calling the overloaded parameter process, clearing the address parameter information in the original transmission proxy object, and setting it to the latest address parameter information; and dynamically loading public protocol packages and secondary-developed private protocol packages.
[0011] Optionally, the step of loading public and private dependency plugin packages via a dynamic class manager when the gateway starts includes: converting the dependency plugin packages into URLs, where the dependency plugin packages are JAR files; adding a set of URL resources for class lookup via a custom class loader; clearing the class loading cache of the JAR files; storing the newly created class loader in a memory-mapped table with the dependency package name as the key; if the switch parameter for enabling loading private dependency plugin packages is set to true, then all private JAR files need to be loaded, and the loading mechanism of private dependency plugin packages is the same as that of dependency plugin packages.
[0012] Optionally, after the dependent plugin package is loaded, the method to start listening on the transmission port is called to traverse the address information bound to the gateway for information loading and starting listening. This includes: calling the start transmission method through the transmission manager, creating a new transmission proxy object, and calling the start method to start listening; obtaining the communication protocol class from the memory-mapped table according to the protocol class path information configured for the address through the dynamic class loading manager; instantiating the communication protocol class and checking whether the instantiated type is a data communication type; initializing the address parameter information; executing the transmission thread through the thread pool and starting address port listening, changing the address running state to the started state; and storing the newly started transmission object in the memory-mapped table with the address name as the key and the transmission proxy object as the value.
[0013] Optionally, the step of calling the start transmission method through the transmission manager to lock the enable operation includes: checking the current address's startup status; if the current address is not in a startup state, then calling the start transmission method through the transmission manager, creating a new transmission proxy object, calling the start transmission method to perform a startup listening operation, and storing the newly created transmission proxy object in a memory mapping table.
[0014] Optionally, the step of obtaining the transport proxy object in the memory mapping table based on the address's English name and locking the deactivation operation includes: checking the current address's startup status; if the current address is in a startup state, calling the transport object's shutdown method to close the listening and connection, and changing the address's running status to a stopped state.
[0015] Optionally, the dynamic loading of public protocol packages and secondary-developed private protocol packages includes: in the JAR package list tab of the unified operation and management platform, for a single JAR package, calling the logic to load public JAR packages, and loading public protocol packages and secondary-developed private protocol packages through a dynamic class loading manager.
[0016] Optionally, a gateway includes at least one gateway running instance, and the gateway running instance is deployed on a server.
[0017] According to a second aspect of the present invention, a system for dynamically loading plugins and starting / stopping ports based on a microservice gateway is provided, comprising: a first dynamic loading module, used to load public dependency plugin packages and private dependency plugin packages through a dynamic loading class manager when the gateway starts; a listening execution module, used to call a method to start listening on the transmission port after the dependency plugin packages are loaded, traversing the address information bound to the gateway to load information and start listening; a first query module, used to respond to a query command for deployed gateways, query deployed gateways through a registry center interface on the online gateway management interface, and display gateway running instances; and a second query module, used to respond to a command to view the address information of a gateway running instance, query the address information of all deployed gateways in the database, compare it with the addresses loaded by the protocol in the memory mapping table, and return the address containing the address. The system includes: an address status module; a dynamic operation execution module, used to respond to address information management commands and perform enable, disable, restart, or parameter refresh operations on a single address without restarting the gateway; the enable operation includes calling the enable transmission method through the transmission manager and locking the enable operation; the disable operation includes retrieving the transmission proxy object from the memory mapping table based on the address's English name and locking the disable operation; the restart operation includes calling the disable and enable methods sequentially; the parameter refresh operation includes retrieving the latest address parameter information from the distributed cache, retrieving the transmission proxy object based on the address, calling the overloaded parameter process, clearing the address parameter information in the original transmission proxy object, and setting it to the latest address parameter information; and a second dynamic loading module, used to dynamically load public protocol packages and secondary-developed private protocol packages.
[0018] According to a third aspect of the present invention, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method described above.
[0019] According to a fourth aspect of the present invention, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements the steps of the above-described method.
[0020] The present invention provides a method and system for dynamically loading plugins and starting / stopping ports based on a microservice gateway, which has the following beneficial effects:
[0021] 1. It enables dynamic loading of dependency plugin packages without restarting the gateway, avoiding interruption of request processing caused by restarting the gateway service after modifying the dependency plugin packages, and ensuring continuous operation in scenarios with strict high availability requirements (such as financial transactions and real-time communication).
[0022] 2. Supports starting, stopping, restarting, and refreshing parameters for a single port without restarting the gateway, achieving millisecond-level effect, ensuring stable system operation, and avoiding the problem that starting or stopping a port requires restarting the entire gateway, affecting all services.
[0023] 3. It provides the ability to monitor all instance information of the gateway during runtime, enhancing the manageability of the system.
[0024] 4. It enables production to be launched without downtime and without affecting other business operations, thus improving the overall availability and stability of the system. Attached Figure Description
[0025] The accompanying drawings, which are provided to further illustrate this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application.
[0026] Figure 1 This is the overall flowchart of the present invention.
[0027] Figure 2 This is a system framework diagram of the present invention.
[0028] Figure 3 This is a schematic diagram of an electronic device. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] Example 1
[0031] To address the shortcomings of current native microservice gateways, such as lack of support for dynamically loading dependency plugin packages, dynamic start / stop of non-native gateway business ports, and lack of non-downtime update capabilities for gateway runtime memory, this application provides a method for dynamically loading plugins and starting / stopping ports based on a microservice gateway. Please refer to... Figure 1 This method enables dynamic management of multi-protocol ports without interrupting gateway services, thereby improving system flexibility and availability. Specifically, it includes the following steps.
[0032] S1. When the gateway starts, it loads public and private dependency plugin packages through a dynamic class manager.
[0033] In one embodiment of the present invention, when the gateway starts, a public dependency plugin package and a private dependency plugin package are loaded via a dynamic class manager. This includes: converting the dependency plugin package into a URL, where the dependency plugin package is a JAR file; adding a set of URL resources for class lookup using a custom class loader (e.g., JarFileClassLoader); clearing the class loading cache of the JAR file; storing the newly created class loader as a key in a memory mapping table (specifically, a public class loader mapping table, i.e., a publicClassloaderMap); and setting a Java collection type declaration: Map.<String,JarFileClassLoader> This represents a key-value mapping relationship, where the key is a string type and the value is an instance of type JarFileClassLoader, used for subsequent class loading. If the switch to load private dependency plugin packages (reloadAllPriJar) is set to true, then all private JAR packages need to be loaded, and the loading mechanism of private dependency plugin packages is the same as that of dependency plugin packages.
[0034] It should be noted that the loading mechanism for private dependency plugin packages is the same as that for dependency plugin packages. Specifically, after loading all private JAR packages, each private JAR package is converted into a URL. Then, a set of URL resources for class lookup is added through a custom class loader JarFileClassLoader. The previous class loading cache for that private JAR package is cleared, and the newly created class loader is stored in the memory mapping table with the dependency package name as the key. All private JAR packages are loaded according to the above loading mechanism.
[0035] S2. After the dependent plugin packages are loaded, call the method to start listening on the transmission port, traverse the address information bound to the gateway to load information and start listening.
[0036] After the dependent plugin packages are loaded, the method to start listening on the transport port is called. This involves iterating through the address information bound to the gateway to load information and start listening, including: calling the startTransport method through the TransportManager, creating a new TransportProxy object, and calling the start method to start listening; retrieving the communication protocol class from the memory-mapped table based on the protocol class path information configured for the address using the dynamic class manager; instantiating the communication protocol class and checking if the instantiated type is the data communication Transport type; initializing the address parameter information; executing the transport thread TransportRunner through the thread pool and starting address port listening, changing the address running state to the started state; and setting a Java collection type declaration: Map, with the address name as the key and the TransportProxy object as the value for the newly started transport object.<String, TransportProxy> This represents a key-value pair mapping relationship, where the key is a string type and the value is an instance of TransportProxy, stored in an in-memory mapping table (specifically: the in-memory inbound transport proxy mapping table, i.e., the in-memory InboundTransportProxyMap), for online gateway viewing.
[0037] It should be noted that the memory mapping tables involved in this application include two types of memory mapping tables: the memory inbound transport proxy mapping table and the memory public class loader mapping table.
[0038] S3 responds to the query command for deployed gateways. In the online gateway management interface, it queries deployed gateways through the registration center interface and displays gateway running instances.
[0039] In one embodiment of the present invention, the unified operation and management platform provides an online gateway management and query function for deployed gateways. In the "Online Gateway Management" interface, deployed gateways can be queried through the registration center interface and the running instances of the gateways can be displayed.
[0040] In one embodiment of the present invention, upon entering the "Online Gateway Management" interface, users can query the deployed gateways. The gateway information includes the service name, Chinese name of the project, English name of the project, gateway type, and number of instances. Clicking on a single gateway allows users to view the specific running instances of the gateway. A gateway may include multiple gateway running instances. A gateway running instance is generally deployed on a server. The gateway running instance list is mainly used to display the IP address of the server where the instance is running.
[0041] S4. Respond to the command to view the address information of the gateway running instance, query the address information of all deployed gateways in the database, compare it with the address loaded by the protocol in the memory mapping table, and return the address information including the address status.
[0042] In one embodiment of the present invention, an address information (i.e. endpoint information) viewing function can be provided for each gateway running instance. The address information of all deployed gateways in the database is queried, and then compared with the address loaded by the protocol in the memory mapping table (specifically: memory inbound transport agent mapping table), and the address information containing the address status is returned.
[0043] In one embodiment of the present invention, clicking on the right side of the gateway running instance enters the address information (endpoint information) management interface, where all addresses under the gateway running instance can be viewed, including addresses and ports that are deployed but not yet started and those that are started and running. The address information includes address name, address port, address protocol name, protocol service class, message component name, and address status. It supports viewing address parameter information in the running memory. The address parameter information includes keep-alive, timeout (seconds), buffer size, character set, message length encoding method, message length inclusion method, start byte of received message length, end byte of received message length, start byte of sent message length, end byte of sent message length, length data alignment, length padding character (hexadecimal), heartbeat packet, length separator (hexadecimal), transaction code xpath, transaction code start label, transaction code end label, etc. These parameters together determine how the system parses and processes non-HTTP protocol messages.
[0044] S5 responds to address information management commands and performs enable, disable, restart, or parameter refresh operations on a single address without restarting the gateway.
[0045] The activation operation includes: calling the startTransport method through the TransportManager and locking the activation operation. The specific implementation of this operation is as follows: check the startup status of the current address; if the current address is not in a startup state, call the startTransport method through the TransportManager, create a new TransportProxy object, call the startTransport method again to perform a startup listening operation, and store the newly created TransportProxy object in a memory mapping table (specifically: a memory inbound transport proxy mapping table).
[0046] The deactivation operation includes: retrieving the transport proxy object from the memory mapping table (specifically, the memory inbound transport proxy mapping table) based on the address's English name, and locking the deactivation operation. The specific implementation of this operation is as follows: check the current address's startup status; if the current address is in a startup state, call the transport object's close method to close the listening and connection, and change the address's running status to a stopped state.
[0047] The restart operation includes sequentially calling the disable and enable methods. It should be noted that the disable and enable methods are the same as those described in the preceding disable and enable operations.
[0048] The parameter refresh operation includes: obtaining the latest address parameter information in the distributed cache, obtaining the transport proxy object based on the address, calling the overloaded parameter process, clearing the address parameter information in the original transport proxy object, and setting it as the latest address parameter information.
[0049] This system supports starting, stopping, restarting, and refreshing parameters for a single address without restarting the gateway, with effects taking effect in milliseconds to ensure stable system operation.
[0050] S6. Dynamically load public protocol packages and private protocol packages developed through secondary development.
[0051] Dynamically loading public protocol packages and secondary-developed private protocol packages involves: on the unified operation and management platform's JAR package list tab, for a single JAR package, calling the logic to load public JAR packages, and loading public protocol packages and secondary-developed private protocol packages through a dynamic class manager. This dynamic loading mechanism is the same as the dynamic loading mechanism in step S1 (specifically, loading public and private dependency plugin packages through a dynamic class manager when the gateway starts), and will not be elaborated further here. This mechanism of dynamically loading public protocol packages and secondary-developed private protocol packages for each gateway instance enables production deployment without downtime and without affecting other services, while also avoiding the need to restart the entire gateway service, thus improving system flexibility and availability.
[0052] This system also provides monitoring functions for all instances of the gateway during runtime, as well as monitoring of all address and port information, address protocols, address packet adapters, and address parameter information in the memory of each instance of the gateway during runtime. In the unified operation and management platform, this information is displayed through a visual interface; for example, different colors are used to distinguish multiple running instances of a single gateway, allowing administrators to intuitively understand the address information of each running instance of the gateway.
[0053] By using this method of dynamically loading plugins and starting / stopping ports based on a microservice gateway, the system achieves flexible management and configuration of non-HTTP protocol ports. Port configurations can be dynamically adjusted without restarting the entire gateway service, greatly improving system maintainability and operational efficiency. Meanwhile, real-time monitoring and visualization capabilities make system management more intuitive and convenient, effectively enhancing operational efficiency.
[0054] Example 2
[0055] Based on Embodiment 1 above, this embodiment also provides a system 200 for dynamically loading plugins and starting / stopping ports based on a microservice gateway. Please refer to [link to relevant documentation]. Figure 2 The system is used to implement the steps of dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in Embodiment 1 above. The main implementation modules of the system are: a first dynamic loading module 201, a listening execution module 202, a first query module 203, a second query module 204, a dynamic operation execution module 205, and a second dynamic loading module 206.
[0056] In one embodiment of the present invention, the first dynamic loading module 201 is used to load public dependency plugin packages and private dependency plugin packages through a dynamic loading class manager when the gateway starts.
[0057] In one embodiment of the present invention, the listening execution module 202 is used to call the transmission port start listening method after the dependent plugin package is loaded, and to traverse the address information bound to the gateway to load information and start listening.
[0058] In a preferred embodiment of the present invention, the first query module 203 is used to respond to the query command for deployed gateways, and to query deployed gateways and display gateway running instances through the registration center interface on the online gateway management interface.
[0059] In one embodiment of the present invention, the second query module 204 is used to respond to the instruction to view the address information of the gateway running instance, query the address information of all deployed gateways in the database, compare it with the address loaded by the protocol in the memory mapping table, and return address information including address status.
[0060] In a preferred embodiment of the present invention, the dynamic operation execution module 205 is used to respond to address information management instructions and perform enable, disable, restart, or parameter refresh operations on a single address without restarting the gateway; wherein: the enable operation includes: calling the enable transmission method through the transmission manager and locking the enable operation; the disable operation includes: obtaining the transmission proxy object in the memory mapping table according to the address's English name and locking the disable operation; the restart operation includes: calling the disable method and the enable method in sequence; the parameter refresh operation includes: obtaining the latest address parameter information in the distributed cache, obtaining the transmission proxy object according to the address, calling the reloaded parameter process, clearing the address parameter information in the original transmission proxy object, and setting it as the latest address parameter information.
[0061] In one embodiment of the present invention, the second dynamic loading module 206 is used to dynamically load public protocol packages and secondary developed private protocol packages.
[0062] In summary, the system adopts a microservice architecture, with modules communicating through standard interfaces, exhibiting high scalability and flexibility. The memory-mapped table, as a core component, provides basic data support for each module; the first query module, the second query module, and the dynamic operation execution module are responsible for handling external commands and executing specific operations; the first and second dynamic loading modules support the dynamic loading of public dependency plugin packages, private dependency plugin packages, public protocol packages, and secondary developed private protocol packages without requiring a gateway restart. All modules work collaboratively to achieve efficient and flexible dynamic loading of gateway plugins and port management functions.
[0063] Example 3
[0064] Based on Embodiment 1 described above, this embodiment also provides an electronic device, please refer to the appendix. Figure 3 , Figure 3 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0065] like Figure 3 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the electronic device. The processing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0066] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, etc.; storage devices 308 including, for example, magnetic tapes, hard disks, etc.; and communication devices 309. Communication device 309 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 3 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively. Figure 3 Each box shown can represent a device or multiple devices as needed.
[0067] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 309, or installed from storage device 308, or installed from ROM 302. When the computer program is executed by processing device 301, it performs the functions defined in the methods of some embodiments of this disclosure.
[0068] Example 4
[0069] Based on Embodiment 1 above, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above method.
[0070] It should be noted that, in some embodiments of this disclosure, the computer-readable medium described above may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), or any suitable combination thereof.
[0071] In this embodiment, the client and server can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0072] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0073] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0074] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), etc.
[0075] Obviously, those skilled in the art will understand that the various steps of the present invention described above can be performed in a manner different from that described above, and the simulation methods and experimental equipment include, but are not limited to, the above description. The steps of the present invention described above can be performed in a different order in certain circumstances, and the steps shown or described above can be performed separately. Therefore, the present invention is not limited to any particular combination of hardware and software.
[0076] The above description, in conjunction with specific embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such deductions or substitutions should be considered within the scope of protection of the present invention.
Claims
1. A method for dynamically loading plugins and starting / stopping ports based on a microservice gateway, characterized in that, include: When the gateway starts, it loads public and private dependency plugin packages through a dynamic class manager. After the dependent plugin packages are loaded, the method to start listening on the transmission port is called to iterate through the address information bound to the gateway to load information and start listening. In response to the query command for deployed gateways, the system queries deployed gateways through the registry center interface in the online gateway management interface and displays the gateway running instances. In response to the command to view the address information of the gateway running instance, query the address information of all deployed gateways in the database, compare it with the address loaded by the protocol in the memory mapping table, and return address information including address status; In response to address information management commands, perform enable, disable, restart, or parameter refresh operations on a single address without restarting the gateway; among which: The activation process includes: calling the enable transfer method through the transfer manager and locking the activation operation; The deactivation operation includes: retrieving the transport proxy object from the memory-mapped table based on the address's English name, and locking the deactivation operation; The restart operation includes: sequentially calling the disable method and the enable method; The parameter refresh operation includes: obtaining the latest address parameter information in the distributed cache, obtaining the transport proxy object based on the address, calling the reloaded parameter process, clearing the address parameter information in the original transport proxy object, and setting it as the latest address parameter information; Dynamically load public protocol packages and privately developed protocol packages.
2. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, The process of loading public and private dependency plugin packages via a dynamic class manager when the gateway starts includes: Convert the dependency plugin package into a URL, where the dependency plugin package is a JAR file; Add a set of URL resources for class lookup by using a custom class loader; Clear the class loading cache of the JAR package and store the newly created class loader in the memory mapping table with the dependency package name as the key; If the switch parameter for enabling loading private dependency plugin packages is set to true, then all private JAR packages will be loaded, and the loading mechanism for private dependency plugin packages will be the same as that for dependency plugin packages.
3. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, After the dependent plugin package is loaded, the method to start listening on the transmission port is called, which iterates through the address information bound to the gateway to load information and start listening, including: The start transmission method is called through the transmission manager to create a new transmission proxy object, and the start method is called to start the listening operation. By dynamically loading the class manager, the communication protocol class is obtained from the memory-mapped table based on the protocol class path information configured at the address; Instantiate the communication protocol class and check whether the instantiated type is a data communication type; Initialize address parameter information; The transmission thread is executed through a thread pool and the address port is started to listen; the address running state is changed to the running state. The newly opened transport object is stored in the memory-mapped table with the address name as the key and the transport proxy object as the value.
4. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, The step of calling the enable transmission method through the transmission manager to lock the enable operation includes: Check the startup status of the current address. If the current address is not in a startup state, call the Start Transmission method through the transmission manager, create a new transmission proxy object, call the Start Transmission method to start the listening operation, and store the newly created transmission proxy object in the memory mapping table.
5. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, The step of retrieving the transport proxy object from the memory mapping table based on the address's English name and locking the deactivation operation includes: Check the current address's startup status. If the current address is in a startup state, call the close method of the transport object to close the listening and connection, and change the address's running status to a stopped state.
6. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, The dynamic loading of public protocol packages and secondary-developed private protocol packages includes: On the JAR package list tab of the unified operation and management platform, for a single JAR package, the logic for loading public JAR packages is invoked, and public protocol packages and secondary development private protocol packages are loaded through a dynamic class loading manager.
7. The method for dynamically loading plugins and starting / stopping ports based on a microservice gateway as described in claim 1, characterized in that, A gateway includes at least one gateway running instance, and the gateway running instance is deployed on a server.
8. A system for dynamically loading plugins and starting / stopping ports based on a microservice gateway, characterized in that, include: The first dynamic loading module is used to load public and private dependency plugin packages through a dynamic class manager when the gateway starts. The listening execution module is used to call the method to start listening on the transmission port after the dependent plugin package has been loaded, and to traverse the address information bound to the gateway to load information and start listening. The first query module is used to respond to the query command for deployed gateways. On the online gateway management interface, it queries deployed gateways through the registration center interface and displays gateway running instances. The second query module is used to respond to the command to view the address information of the gateway running instance, query the address information of all deployed gateways in the database, compare it with the address loaded by the protocol in the memory mapping table, and return address information including address status. The dynamic operation execution module is used to respond to address information management commands and perform enable, disable, restart, or parameter refresh operations on a single address without restarting the gateway; among which: The activation process includes: calling the enable transfer method through the transfer manager and locking the activation operation; The deactivation operation includes: retrieving the transport proxy object from the memory-mapped table based on the address's English name, and locking the deactivation operation; The restart operation includes: sequentially calling the disable method and the enable method; The parameter refresh operation includes: obtaining the latest address parameter information in the distributed cache, obtaining the transport proxy object based on the address, calling the reloaded parameter process, clearing the address parameter information in the original transport proxy object, and setting it as the latest address parameter information; The second dynamic loading module is used to dynamically load public protocol packages and private protocol packages developed through secondary development.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.