A dynamic message routing method, apparatus, device and medium

By employing multithreading technology and component-based design, the problem of low efficiency in single-threaded message processing is solved, achieving efficient and stable data synchronization and dynamic expansion, thereby improving the maintainability and stability of the system.

CN116455912BActive Publication Date: 2026-01-02SHANGHAI YUER NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310253804.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-16
Publication Date
2026-01-02
Estimated Expiration
2043-03-16

AI Technical Summary

Technical Problem

Existing technologies, in incremental data synchronization scenarios, employ single-threaded message processing, resulting in low efficiency, high error rates, difficulty in expansion and maintenance, and poor stability.

Method used

Multithreading technology is used for message processing, and dynamic scene online/offline operation is achieved through an event dispatcher and a virtual signal bus. The system adopts a modular design and applies computer hardware design principles.

Benefits of technology

It improves message processing efficiency and sending/receiving performance, reduces error rate, enhances system scalability and maintainability, and ensures system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116455912B_ABST
    Figure CN116455912B_ABST
Patent Text Reader

Abstract

The application provides a dynamic message routing method, device, equipment and medium. The method comprises the following steps: obtaining first target information corresponding to a target message collector from a message processing center; querying second target information corresponding to the first target information; sending the second target information to the message processing center, so that the message processing center determines a target message transmitter and obtains target corresponding information; sending the target corresponding information to the target message collector by the message processing center, so that the target message collector transmits an initial message to the target message transmitter; sending the initial message to the message processing center for processing by the target message transmitter, so as to obtain a target message; and sending the target message to the target message transmitter by the message processing center, so that the target message transmitter sends the target message to an external message collector. The scheme adopts a multi-thread technology to process messages, improves efficiency, reduces error rate, is easy to expand and maintain, and has high stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of message routing technology, and in particular to a dynamic message routing method, apparatus, device, and medium. Background Technology

[0002] Currently, such as Figure 1 As shown, in incremental data synchronization scenarios, it's necessary to synchronize data from multiple tables into a single wide table based on customized business requirements. This synchronization typically involves using binary log messages from multiple tables within the customized scenario. To maintain data order within the wide table—meaning messages received earlier should be processed first, and later messages processed later—the data from the same wide table within the same scenario needs to be sent to the same partition within a high-throughput distributed publish-subscribe messaging system (Kafka) based on the primary key. This ensures that the processing occurs within the same thread.

[0003] In the above process, single-threaded technology is used for message processing. Furthermore, adding and deleting scenarios requires modifying the code and redeploying, resulting in low message processing efficiency, high error rate, difficulty in expansion and maintenance, and poor stability. Summary of the Invention

[0004] This application provides a dynamic message routing method, apparatus, device, and medium to overcome the shortcomings of the prior art. It employs multi-threading technology for message processing, which can improve message processing efficiency, reduce error rate, and is easy to expand, maintain, and maintain with high stability.

[0005] To solve the above-mentioned technical problems, this application provides the following technical solution:

[0006] According to a first aspect of the embodiments of this application, a dynamic message routing method is provided, including:

[0007] The first target information corresponding to the target message collector in the message sending and receiving processing engine is obtained from the message processing center in the message sending and receiving processing engine; the first target information is transmitted from the target message collector to the message processing center, and the target message collector is the message collector that has listened to the initial message.

[0008] Query the information corresponding to the first target information to obtain the second target information;

[0009] sending the second target information to the message processing center, so that the message processing center determines a target message transmitter corresponding to the second target information in the message processing and transmission engine based on the second target information, to obtain target corresponding information; and so that the message processing center sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message transmitter based on the target corresponding information; and so that the target message transmitter sends the initial message to the message processing center for processing, to obtain a target message; and so that the message processing center sends the target message to the target message transmitter, so that the target message transmitter sends the target message to an external message collector.

[0010] In an exemplary embodiment, the method further comprises a scene dynamic on- and off-line step, which comprises:

[0011] obtaining scene on- and off-line configuration information from the message processing and transmission engine; the scene on- and off-line configuration information is determined based on an event dispatcher;

[0012] based on the scene on- and off-line configuration information, obtaining a scene configuration that needs to be changed; and based on the scene on- and off-line configuration information, updating a current routing table to obtain an updated routing table;

[0013] sending the scene configuration that needs to be changed to the message processing and transmission engine, so that the message processing and transmission engine updates the message transmitter and the message collector to obtain an updated message transmitter and an updated message collector.

[0014] In an exemplary embodiment, the method further comprises an initialization and start step, which comprises:

[0015] pulling an initial scene configuration from an external configuration center;

[0016] initializing a routing table based on the initial scene configuration to obtain an initial routing table;

[0017] starting and updating a routing state, so that the message processing and transmission engine obtains an initial message collector and an initial message transmitter corresponding to the initial scene configuration, and mounts the initial message collector and the initial message transmitter, to complete the initialization of the message processing and transmission engine; and so that the message processing and transmission engine starts and updates an engine state.

[0018] In an exemplary embodiment, the scene dynamic on- and off-line comprises a scene dynamic on-line and a scene dynamic off-line, and the scene dynamic on-line step comprises:

[0019] obtaining scenario online configuration information from the message communication processing engine;

[0020] based on the scenario online configuration information, obtaining a newly added scenario configuration; and based on the scenario online configuration information, updating the current routing table to obtain a first routing table;

[0021] sending the newly added scenario configuration to the message communication processing engine, so that the message communication processing engine obtains a newly added message sender and a newly added message collector; and so that the message communication processing engine inserts the newly added message sender and the newly added message collector into a slot and starts.

[0022] In an exemplary embodiment, the scenario dynamic offline step includes:

[0023] obtaining scenario offline configuration information from the message communication processing engine;

[0024] based on the scenario offline configuration information, obtaining a scenario configuration to be deleted; and based on the scenario offline configuration information, updating the current routing table to obtain a second routing table;

[0025] sending the scenario configuration to be deleted to the message communication processing engine, so that the message communication processing engine obtains a message sender to be deleted and a message collector to be deleted; and so that the message communication processing engine destroys threads of the message sender to be deleted and the message collector to be deleted and removes the message sender to be deleted and the message collector to be deleted from the slot.

[0026] In an exemplary embodiment, the obtaining of the scenario online / offline configuration information from the message communication processing engine is based on an event dispatcher and includes:

[0027] The scenario online / offline configuration information is obtained from the message communication processing engine and is determined based on a virtual signal bus converting configuration signals into semaphores, the virtual signal bus being implemented based on a function of the event dispatcher; the configuration signals are determined based on the event dispatcher analyzing scenario online / offline events; and the scenario online / offline events are determined based on an external event sensor.

[0028] According to a second aspect of the embodiments of the present application, a dynamic message routing device is provided, and the device includes:

[0029] The first obtaining module is configured to obtain first target information corresponding to a target message collector in the messaging processing engine from a message processing center in the messaging processing engine; the first target information is transmitted to the message processing center by the target message collector, and the target message collector is a message collector that listens to an initial message;

[0030] The second obtaining module is configured to query information corresponding to the first target information to obtain second target information;

[0031] The information processing module is configured to send the second target information to the message processing center, so that the message processing center determines a target message transmitter corresponding to the second target information in the messaging processing engine based on the second target information to obtain target corresponding information; and so that the message processing center sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message transmitter based on the target corresponding information; and so that the target message transmitter sends the initial message to the message processing center for processing to obtain a target message; and so that the message processing center sends the target message to the target message transmitter, so that the target message transmitter sends the target message to an external message collector.

[0032] According to a third aspect of the embodiments of the present application, an electronic device is provided, which comprises a processor and a memory, the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program is loaded and executed by the processor to implement the dynamic message routing method described above.

[0033] According to a fourth aspect of the embodiments of the present application, a computer readable storage medium is provided, the storage medium stores at least one instruction or at least one program, the at least one instruction or the at least one program is loaded and executed by a processor to implement the dynamic message routing method described above.

[0034] By using the above technical solutions, the present application has the following beneficial effects:

[0035] (1) The multi-threading technology is used for message processing, which can improve the message processing efficiency and the message transmission performance, and reduce the error rate;

[0036] (2) The computer hardware design idea is applied to software design, which realizes the dynamic pluggable function and improves the expansibility;

[0037] (3) By componentizing the function modules, the function boundary is determined, and the maintainability of the overall project is enhanced;

[0038] (4) The virtual signal bus realized by the event dispatcher and its functions avoids mutual interference between scenes, and makes the overall system have high stability. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.

[0040] Figure 1 A flowchart of a message routing method provided by the prior art;

[0041] Figure 2 A flowchart of a dynamic message routing method provided by the embodiments of the present application;

[0042] Figure 3 A flowchart of scene dynamic online and offline provided by the embodiments of the present application;

[0043] Figure 4 A flowchart of initialization and start provided by the embodiments of the present application;

[0044] Figure 5 A flowchart of scene dynamic online provided by the embodiments of the present application;

[0045] Figure 6 A flowchart of scene dynamic offline provided by the embodiments of the present application;

[0046] Figure 7 An overall module design diagram of the dynamic message routing method provided by the embodiments of the present application;

[0047] Figure 8 A dependency relationship diagram of each component of the dynamic message routing method provided by the embodiments of the present application;

[0048] Figure 9 A flowchart of message transmission provided by the embodiments of the present application;

[0049] Figure 10 A flowchart of scene configuration online provided by the embodiments of the present application;

[0050] Figure 11 A flowchart of scene configuration offline provided by the embodiments of the present application;

[0051] Figure 12 A structural block diagram of a dynamic message routing device provided by the embodiments of the present application;

[0052] Figure 13 This is a hardware structure block diagram of an electronic device that runs a dynamic message routing method, as provided in an embodiment of this application. Detailed Implementation

[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0054] The term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of this application. In the description of the embodiments of this application, it should be understood that the terms "upper," "lower," "top," "bottom," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" and "second" may explicitly or implicitly include one or more of that feature. Moreover, the terms "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein.

[0055] Please see Figure 2 The diagram shown is a flowchart of a dynamic message routing method provided in an embodiment of this application. The dynamic message routing method includes:

[0056] Step S101: Obtain the first target information corresponding to the target message collector in the message sending and receiving processing engine from the message processing center in the message sending and receiving processing engine; the first target information is transmitted from the target message collector to the message processing center, and the target message collector is the message collector that has listened to the initial message;

[0057] Step S102: Query the information corresponding to the first target information to obtain the second target information;

[0058] Step S103: sending the second target information to the message processing center, so that the message processing center determines a target message sender corresponding to the second target information in the message processing engine based on the second target information, obtains target corresponding information, and sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message sender based on the target corresponding information; and so that the target message sender sends the initial message to the message processing center for processing, obtains a target message, and sends the target message to the target message sender by the message processing center, so that the target message sender sends the target message to an external message collector.

[0059] In one specific embodiment, the message collector that listens to the initial message is determined as the target message collector by step S101, and the first target message corresponding to the target message collector is obtained; the second target information corresponding to the first target information is queried by step S102; the target message sender corresponding to the second target information, i.e., the target message sender corresponding to the target message collector, is determined by step S103, and the target corresponding information between the target message sender and the target message collector is obtained, so that the target message collector transmits the initial message to the message processing center for processing based on the target corresponding information, obtains a target message, and the message processing center sends the target message to the target message sender, and then the target message sender sends the target message to an external message collector. This technical solution uses multi-thread technology for message processing, which can improve the message processing efficiency and the message transmission performance, reduce the error rate, and by componentizing the functional modules, the functional boundaries are determined, and the maintainability of the overall project is enhanced.

[0060] The above method further includes a step of dynamically online and offline of a scene, please refer to Figure 3 which is a flowchart of dynamically online and offline of a scene provided by an embodiment of the present application, which can include:

[0061] Step S201: obtaining scene online and offline configuration information from the message processing engine; the scene online and offline configuration information is determined based on an event dispatcher;

[0062] Step S202: obtaining a scene configuration to be changed based on the scene online and offline configuration information, and updating a current routing table based on the scene online and offline configuration information to obtain an updated routing table;

[0063] Step S203: sending the scene configuration to be changed to the message transceiving processing engine, so that the message transceiving processing engine updates the message sender and the message collector to obtain an updated message sender and an updated message collector.

[0064] In one specific embodiment, by step S201, scene online and offline configuration information is acquired, which is distributed by an event distributor; by step S202, scene configuration to be changed is determined, i.e., scene configuration that needs to be added or deleted is determined, and a current routing table is updated to obtain an updated routing table; by step S203, the message transceiving processing engine is caused to update the current message sender and the current message collector according to the scene configuration to be changed to obtain an updated message sender and an updated message collector, i.e., the message transceiving processing engine adds or deletes the current message sender and the current message collector according to the scene configuration to be changed. By applying the computer hardware design idea to software design, dynamic pluggability of functions is achieved, and expandability is improved.

[0065] The above method further includes the steps of initialization and starting, please refer to Figure 4 which is a flowchart of initialization and starting provided by an embodiment of the application, and the flowchart can include:

[0066] Step S301: pulling an initial scene configuration from an external configuration center;

[0067] Step S302: initializing a routing table based on the initial scene configuration to obtain an initial routing table;

[0068] Step S303: starting and updating a routing state, so that the message transceiving processing engine acquires an initial message collector and an initial message sender corresponding to the initial scene configuration, and mounts the initial message collector and the initial message sender, to complete initialization of the message transceiving processing engine; and so that the message transceiving processing engine starts and updates an engine state.

[0069] In one specific embodiment, by step S301, a preset initial scene configuration in an external configuration center is pulled, and the initial scene configuration can be determined according to a demand of a business for a configuration scene and a message routing strategy; by step S302, an initial routing table is obtained according to the initial scene configuration; and by step S303, a routing state is started and updated, so that the message transceiving processing engine mounts an initial message collector and an initial message sender, to complete initialization and start and update a state.

[0070] The above scene dynamic online and offline includes scene dynamic online and scene dynamic offline, please refer to Figure 5As shown in the figure, the figure is a flow diagram of a scenario dynamic online process provided by an embodiment of the application, and the flow can include the following steps:

[0071] Step S401: Obtain scenario online configuration information from the message transmission processing engine.

[0072] Step S402: Obtain added scenario configuration based on the scenario online configuration information, and update the current routing table based on the scenario online configuration information to obtain a first routing table.

[0073] Step S403: Send the added scenario configuration to the message transmission processing engine, so that the message transmission processing engine obtains an added message transmitter and an added message collector, and so that the message transmission processing engine inserts the added message transmitter and the added message collector into a slot and starts.

[0074] In one specific embodiment, the scenario online configuration information is obtained through step S401, the scenario configuration that needs to be added is determined according to the scenario online configuration information through step S402, the added scenario configuration is obtained, and the current routing table is updated to obtain a first routing table, that is, the routing table information that needs to be added is added to the current routing table to obtain the first routing table; the added scenario configuration is sent to the message transmission processing engine through step S403, so that the message transmission processing engine adds the added message transmitter and the added message collector corresponding to the added scenario configuration, and starts after inserting the added message transmitter and the added message collector into the slot.

[0075] Please refer to Figure 6 As shown in the figure, the figure is a flow diagram of a scenario dynamic offline process provided by an embodiment of the application, and the flow can include the following steps:

[0076] Step S501: Obtain scenario offline configuration information from the message transmission processing engine.

[0077] Step S502: Obtain scenario configuration that needs to be deleted based on the scenario offline configuration information, and update the current routing table based on the scenario offline configuration information to obtain a second routing table.

[0078] Step S503: Send the scenario configuration that needs to be deleted to the message transmission processing engine, so that the message transmission processing engine obtains a message transmitter that needs to be deleted and a message collector that needs to be deleted, and so that the message transmission processing engine destroys the thread of the message transmitter that needs to be deleted and the message collector that needs to be deleted and pulls out the slot.

[0079] In one specific embodiment, by step S501, the scene offline configuration information is acquired; by step S502, according to the scene offline configuration information, the scene configuration to be deleted is determined, the scene configuration to be deleted is obtained, and the current routing table is updated to obtain a second routing table, that is, the routing table information to be deleted is deleted from the current routing table to obtain the second routing table; by step S503, the scene configuration to be deleted is sent to the message transceiving processing engine, so that the message transceiving processing engine deletes the message sender to be deleted and the message collector to be deleted corresponding to the scene configuration to be deleted, and the message sender to be deleted and the message collector to be deleted are pulled out of the slot after the threads are destroyed.

[0080] In one optional embodiment, the above step S201 can include:

[0081] The scene online / offline configuration information is acquired from the message transceiving processing engine; the scene online / offline configuration information is determined based on a virtual signal bus converting configuration signals into semaphores, the virtual signal bus is implemented based on the function of the event dispatcher; the configuration signals are determined based on the event dispatcher analyzing scene online / offline events; the scene online / offline events are perceived based on an external event perceiver.

[0082] Specifically, the event dispatcher analyzes the scene online / offline events, converts the scene online / offline events into configuration signals, and then the virtual signal bus converts the configuration signals into semaphores and sends them to the components in the message transceiving processing engine corresponding thereto.

[0083] Please refer to Figure 7 , which is a whole module design diagram of a dynamic message routing method provided by an embodiment of the application, including two major components: a controller and a router mainboard. The router mainboard includes five basic components, including a message transceiving processing engine, a routing context component, an external event perceiver, an event dispatcher, and a signal bus. The message transceiving processing engine includes four core components, including a message collector, a message routing component, a message processing component, and a message sender. The corresponding relationship of each component is shown in Table 1, and the dependency relationship is shown in Table 2. Figure 8 .

[0084]

[0085]

[0086] Table 1: Component Corresponding Relationship

[0087] Major Component 1: Controller

[0088] The role of the controller is to directly control the initialization and start of the router mainboard, and not to directly control a certain basic component.

[0089] Big component two: router mainboard

[0090] The role of the router mainboard is to initialize and start the basic components. The mainboard has four slots, and the message handling engine, routing context component, event sensor and event distributor are all plugged into the slots of the mainboard. As long as the basic components match the slots, they can be inserted into the router mainboard.

[0091] Basic component one: message handling engine

[0092] The component located in the slot of the router mainboard is responsible for message routing and message processing. The component contains four core components, which are message collector, message routing component, message processing component and message sender.

[0093] Core component one: message collector

[0094] The message collector is responsible for collecting messages

[0095] Core component two: message routing component

[0096] The message routing component is responsible for routing messages to the corresponding message sender

[0097] Core component three: message processing component

[0098] The message processing component is responsible for processing messages and further processing messages before sending

[0099] Core component four: message sender

[0100] The message sender is responsible for sending messages out

[0101] Basic component two: routing context component

[0102] The routing context component saves the routing table and scene configuration, providing routing information for the message handling engine.

[0103] Basic component three: external event sensor

[0104] The external event sensor is used to listen to external events and send the detected events to the event distributor.

[0105] Basic component four: event distributor

[0106] The event distributor is mainly responsible for distributing events and converting events into router signals. The event distributor defines two kinds of router signals, which are configuration change signal and component lifecycle signal.

[0107] Basic component five: signal bus

[0108] Signal bus is used for signal transmission, and is the only way for components to send and receive signals. All signals are sent to the bus, and the signals received by the components also come from the bus.

[0109] Controller implementation:

[0110] The controller realizes the initialization and start control of the router by referencing the router mainboard;

[0111] Router mainboard implementation:

[0112] The four slots on the router mainboard are realized through the interface form. As long as the basic component class that realizes the interface can be inserted into the slot, the program design code is as follows:

[0113] @Component

[0114] public class Route{

[0115] / / Message transmission and reception processing engine

[0116] @A u t o wi re d

[0117] private MessageCenter messageCenter;

[0118] / / External event sensing

[0119] @A u towired

[0120] private ConfigSensor configSensor;

[0121] / / Routing context component

[0122] @A u t o wi re d

[0123] private RouteContext routeContext;

[0124] / / Event dispatcher

[0125] private RouteEventDispatcher routeEventDispatcher=newIntegratedEventDispatcher();

[0126] }

[0127] The message transmission processing engine slot program code is as follows:

[0128] public interface MessageCenter<K, V> extends OnlineOfflineListener, LifecycleListener {

[0129] / / Routing function, routing specific message sender according to route key

[0130] Sender route(String routeKey);

[0131] / / Message processing function, output result according to input processing

[0132] V process(K input) throws ProcessException;

[0133] }

[0134] The router context component slot program code is as follows:

[0135]

[0136]

[0137] The external event sensor slot program code is as follows:

[0138]

[0139] The event dispatcher slot program code is as follows:

[0140]

[0141] The four slots have default base component implementations, and the slot and corresponding default base component class correspondence is shown in Table 2:

[0142]

[0143]

[0144] Table 2 Default Component Implementation

[0145] In the default router, the signal bus and message routing component are virtual concepts, and there is no actual program code class corresponding to them.

[0146] Virtual signal bus:

[0147] The bus concept is realized by the function of the event dispatcher. Components send events through the onEvent() method of the event dispatcher, which converts the events into signals inside the event dispatcher, and converts the signals into a set of semaphore groups that can be operated. The event dispatcher finds all components registered to listen to the signal, and executes the semaphore step by step, thereby realizing the delivery of the signal. Through this implementation, the function of the signal bus is realized. The signals that can be triggered by the events and the corresponding relationship between the signals and the semaphore groups are shown in Table 3.

[0148] event signal a set of semaphores refresh event component lifecycle signals stop, init, start online event configuration change signal online offline event configuration change signal offline

[0149] Table 3: Corresponding relationship between events, signals and semaphore groups

[0150] Virtual message routing component:

[0151] Responsible for routing messages to the specified target address after receiving the messages. The component is a virtual concept. It is realized by the function of the default message collector. After receiving the messages, the message collector obtains the instance of the sender class Sender through the route() method of the IntegratedMessageCenter, and sends the messages to the Sender, thereby realizing the function of the message routing component.

[0152] The specific initialization and start-up process of the default router is as follows:

[0153] The controller controls the initialization and start-up of the router;

[0154] Router initialization:

[0155] 1. The routing context component registers to listen to the component lifecycle signals of the bus;

[0156] 2. The message transceiving processing engine registers to listen to the component lifecycle signals of the bus;

[0157] 3. The message transceiving processing engine registers to listen to the configuration change signals of the bus;

[0158] 4. Initialization of the external event sensor;

[0159] 5. The external event sensor and the event dispatcher are connected.

[0160] Router start-up:

[0161] 1. Send a refresh event to the bus. The refresh event can send three component lifecycle signals: stop signal, initialization signal and start signal, thereby realizing the restart of the components that listen to the component lifecycle signals on the bus;

[0162] 2. Start the external event sensor.

[0163]

[0163] Route context component initialization:

[0164] 1. Pull scenario configuration from external configuration center;

[0165] 2. Initialize routing table.

[0166] Route context component startup:

[0167] 1. Set the route state to the startup state.

[0168] Message processing transceiver engine initialization:

[0169] 1. Call the route context component to obtain all message collectors currently configured;

[0170] 2. Mount the message collector to the message transceiver processing engine;

[0171] 3. Call the route context component to obtain all message senders currently configured;

[0172] 4. Mount the message sender to the message transceiver processing engine.

[0173] Message transceiver processing engine startup:

[0174] 1. Start the message processing component;

[0175] 2. Start the message sender component;

[0176] 3. Start the message collector component;

[0177] 4. Set the engine state to the startup state.

[0178] The default router message transceiver flow is as follows:

[0179] After the route context component is initialized, it has scenario configuration and routing table information; after the message collector is started, it starts to listen to messages; after the message sender is started, it starts to send messages; after the message processing component is started, it has thread pool resources to process messages; after the external sensor component is started, it starts to listen to external events.

[0180] When the message collector receives a message, the data processing flow is as shown in Figure 9 .

[0181] The default router dynamic online and offline flow is as follows:

[0182] When a scenario configuration is online, the corresponding message collector and message sender need to be dynamically inserted, and the flow is as shown in Figure 10 .

[0183] When there is a scene configuration offline, the message collector and the message sender corresponding to the scene need to be dynamically pulled out, and the flowchart is as shown in Figure 11 .

[0184] The above scheme has the following characteristics:

[0185] (1) The message processing core component uses thread pool technology to put all message processing into the thread pool, which solves the message processing problem in message transmission with high performance;

[0186] (2) The abstracted bus concept can extend more events and signals, better monitor the program running state, and has the characteristics of high operation and maintenance;

[0187] (3) The various modules are componentized, and the functional boundaries are determined, so that the code has the characteristics of easy understanding and easy reading;

[0188] (4) The same scene message uses the message collector and the message sender model, and the required message collector and message sender can be customized according to the actual scene, so that similar message transmission problems can be quickly solved;

[0189] (5) The various components are decoupled, and the message collection, message sending, message processing, and forwarding configuration have high expansibility.

[0190] As can be seen from the above technical solutions of the embodiments of the present application, in the embodiments of the present application, the multi-threading technology is used for message processing, which can improve the message processing efficiency and the message transmission performance, and reduce the error rate; the computer hardware design idea is applied to software design, the dynamic pluggable function is realized, and the expansibility is improved; by componentizing the function modules, the functional boundaries are determined, and the maintainability of the overall project is enhanced; the scene dynamic online and offline are realized through the event distributor and the virtual signal bus realized by the function, the mutual interference between scenes is avoided, and the overall system has high stability.

[0191] Corresponding to the dynamic message routing method provided in the above embodiments, the present embodiment also provides a dynamic message routing device. Since the dynamic message routing device provided in the present embodiment corresponds to the dynamic message routing method provided in the above embodiments, the implementation manner of the foregoing dynamic message routing method is also applicable to the dynamic message routing device provided in the present embodiment, which will not be described in detail in the present embodiment.

[0192] Please refer to Figure 12 , which is a structural block diagram of a dynamic message routing device provided in the present embodiment; the device comprises:

[0193] 001: a first obtaining module, configured to obtain first target information corresponding to a target message collector in a message processing engine from a message processing center in the message processing engine; the first target information is transmitted to the message processing center by the target message collector, and the target message collector is a message collector that listens to an initial message;

[0194] 002: a second obtaining module, configured to query information corresponding to the first target information to obtain second target information;

[0195] 003: an information processing module, configured to send the second target information to the message processing center, so that the message processing center determines a target message transmitter corresponding to the second target information in the message processing engine based on the second target information to obtain target corresponding information; and so that the message processing center sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message transmitter based on the target corresponding information; and so that the target message transmitter sends the initial message to the message processing center for processing to obtain a target message; and so that the message processing center sends the target message to the target message transmitter, so that the target message transmitter sends the target message to an external message collector.

[0196] In one specific embodiment, the first obtaining module determines a message collector that listens to an initial message as a target message collector, and obtains first target information corresponding to the target message collector; the second obtaining module queries second target information corresponding to the first target information; and the information processing module determines a target message transmitter corresponding to the second target information, i.e., a target message transmitter corresponding to the target message collector, and obtains target corresponding information between the target message transmitter and the target message collector, so that the target message collector transmits the initial message to the message processing center for processing based on the target corresponding information to obtain a target message, and the message processing center sends the target message to the target message transmitter, and then the target message transmitter sends the target message to an external message collector. This technical solution uses multi-thread technology for message processing, which can improve message processing efficiency and message transmission performance, reduce error rate, and by componentizing functional modules, the functional boundaries are determined, and the maintainability of the overall project is enhanced.

[0197] In one optional embodiment, the above device can further include:

[0198] a configuration obtaining module, configured to obtain scene online and offline configuration information from the message processing engine; the scene online and offline configuration information is determined based on an event dispatcher;

[0199] The configuration updating module is configured to obtain a scene configuration to be changed based on the scene online and offline configuration information, and update a current routing table based on the scene online and offline configuration information to obtain an updated routing table.

[0200] The configuration changing module is configured to send the scene configuration to be changed to the message transceiving processing engine, so that the message transceiving processing engine updates the message sender and the message collector to obtain an updated message sender and an updated message collector.

[0201] Specifically, the scene online and offline configuration information is obtained by the configuration obtaining module, and the scene online and offline configuration information is obtained by an event distributor; the scene configuration to be changed is determined by the configuration updating module, that is, the scene configuration to be added or deleted is determined, and a current routing table is updated to obtain an updated routing table; the message transceiving processing engine updates the current message sender and the current message collector according to the scene configuration to be changed by the configuration changing module to obtain an updated message sender and an updated message collector, that is, the message transceiving processing engine adds or deletes the current message sender and the current message collector according to the scene configuration to be changed. By applying the computer hardware design idea to the software design, the dynamic pluggable function is realized, and the expansibility is improved.

[0202] In an optional embodiment, the apparatus described above can further include:

[0203] The initial configuration pulling module is configured to pull an initial scene configuration from an external configuration center.

[0204] The routing table initializing module is configured to initialize a routing table based on the initial scene configuration to obtain an initial routing table.

[0205] The engine initializing module is configured to start and update a routing state, so that the message processing transceiving engine obtains an initial message collector and an initial message sender corresponding to the initial scene configuration, and mounts the initial message collector and the initial message sender to complete initialization of the message processing transceiving engine, and start and update an engine state.

[0206] Specifically, the initial scene configuration in the external configuration center is pulled by the initial configuration pulling module, and the initial scene configuration can be determined according to the demand of a business for a configuration scene and a message routing strategy; the initial routing table is obtained according to the initial scene configuration by the routing table initializing module; and the routing state is started and updated by the engine initializing module, so that the message processing transceiving engine mounts the initial message collector and the initial message sender to complete initialization and start and update the state.

[0207] It should be noted that the device provided by the above embodiment is only exemplified by the above division of functional modules when realizing its functions. In actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the device and method embodiments provided by the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.

[0208] The dynamic message routing device of the embodiment of the application uses multi-thread technology for message processing, which can improve the message processing efficiency and message transmission performance, and reduce the error rate. The computer hardware design idea is applied to software design to realize dynamic pluggable function and improve the expansibility. By componentizing the functional modules, the functional boundaries are determined, and the maintainability of the overall project is enhanced. The scene dynamic on and off line is realized through the event distributor and the virtual signal bus realized by the function, which avoids mutual interference between scenes, so that the overall system has high stability.

[0209] The embodiment of the application also provides an electronic device, including a processor and a memory, the memory stores at least one instruction or at least one program, the at least one instruction or at least one program is loaded and executed by the processor to realize the dynamic message routing method provided by the above method embodiment.

[0210] The memory can be used to store software programs and modules, and the processor can execute various functional applications and realize high-level automatic driving by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store operating systems, application programs required by functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory can also include a memory controller to provide access to the memory for the processor.

[0211] The method embodiment provided by the embodiment of the application can be executed in a computer terminal, a server or a similar computing device, that is, the above electronic device can include a computer terminal, a server or a similar computing device. Figure 13 is the hardware structure block diagram of the electronic device provided by the embodiment of the application for running a dynamic message routing method, as Figure 13 shown, the internal structure of the electronic device can include but is not limited to a processor, a network interface and a memory. Among them, the processor, the network interface and the memory in the electronic device can be connected through a bus or other means.Figure 13 The bus connection is taken as an example.

[0212] The processor (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device. The network interface can optionally include a standard wired interface, a wireless interface (such as WI-FI, a mobile communication interface, etc.). The memory is a memory device in the electronic device, used to store programs and data. It can be understood that the memory here can be a high-speed RAM memory device, or a non-volatile memory, for example, at least one disk storage device; optionally, it can also be at least one storage device located away from the aforementioned processor. The memory provides a storage space that stores the operating system of the electronic device, which can include but is not limited to: a Windows system (an operating system), a Linux (an operating system), an Android (a mobile operating system) system, an IOS (a mobile operating system) system, etc., and the present application does not limit this; and in the storage space, one or more instructions suitable for being loaded and executed by the processor are also stored, and these instructions can be one or more computer programs (including program codes). In the embodiment of the present application, the processor loads and executes one or more instructions stored in the memory to implement the dynamic message routing method provided by the method embodiment.

[0213] The embodiment of the present application also provides a computer readable storage medium, and the storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the dynamic message routing method provided by the method embodiment.

[0214] Optionally, in the embodiment, the storage medium can include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.

[0215] It should be noted that the above-mentioned sequence of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. And the above describes the specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than the order in which they are recited and still achieve desirable results. In addition, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, parallel processing or parallel processing is also possible or can be advantageous.

[0216] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other. Each embodiment focuses on the difference from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.

[0217] A person of ordinary skill in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program to instruct relevant hardware to complete, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk.

[0218] The above is only the preferred embodiment of the present application, and does not limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A dynamic message routing method, characterized by, Message processing is performed using multi-threading technology, including: obtaining first target information corresponding to a target message collector in the message processing engine from a message processing center in the message processing engine; the first target information is actively transmitted by the target message collector to the message processing center, and the target message collector is a message collector that actively listens to an initial message; querying information corresponding to the first target information to obtain second target information; sending the second target information to the message processing center, so that the message processing center determines a target message sender corresponding to the second target information in the message processing engine based on the second target information to obtain target corresponding information; and so that the message processing center sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message sender based on the target corresponding information; and so that the target message sender sends the initial message to the message processing center for processing to obtain a target message; and so that the message processing center sends the target message to the target message sender, so that the target message sender sends the target message to an external message collector; wherein the first target information is a message collector id corresponding to the target message collector, and the second target information is a message sender id corresponding to the target message sender.

2. The dynamic message routing method of claim 1, wherein, The method further includes a scene dynamic online and offline step, which includes: obtaining scene online and offline configuration information from the message processing engine; the scene online and offline configuration information is determined based on an event distributor; based on the scene online and offline configuration information, obtaining a scene configuration that needs to be changed; and based on the scene online and offline configuration information, updating a current routing table to obtain an updated routing table; sending the scene configuration that needs to be changed to the message processing engine, so that the message processing engine updates the message sender and the message collector to obtain an updated message sender and an updated message collector.

3. The dynamic message routing method of claim 2, wherein, The method further includes an initialization and start step, which includes: pulling an initial scene configuration from an external configuration center; initializing a routing table based on the initial scene configuration to obtain an initial routing table; starting and updating the routing state, so that the message processing engine obtains an initial message collector and an initial message sender corresponding to the initial scene configuration, and mounts the initial message collector and the initial message sender to complete the initialization of the message processing engine; and so that the message processing engine starts and updates the engine state.

4. The dynamic message routing method of claim 2, wherein, The scene dynamic online and offline includes scene dynamic online and scene dynamic offline, and the scene dynamic online step includes: obtaining scene online configuration information from the message processing engine; Based on the scene online configuration information, obtain the added scene configuration; and based on the scene online configuration information, update the current routing table to obtain a first routing table; Send the added scene configuration to the message transceiving processing engine, so that the message transceiving processing engine obtains an added message transmitter and an added message collector; and so that the message transceiving processing engine inserts the added message transmitter and the added message collector into a slot and starts.

5. The dynamic message routing method of claim 4, wherein, The scene dynamic offline step includes: Obtain scene offline configuration information from the message transceiving processing engine; Based on the scene offline configuration information, obtain a scene configuration to be deleted; and based on the scene offline configuration information, update the current routing table to obtain a second routing table; Send the scene configuration to be deleted to the message transceiving processing engine, so that the message transceiving processing engine obtains a message transmitter to be deleted and a message collector to be deleted; and so that the message transceiving processing engine destroys the thread of the message transmitter to be deleted and the message collector to be deleted and pulls out the slot.

6. The dynamic message routing method according to any one of claims 2 to 5, characterized in that, The scene online and offline configuration information is obtained from the message transceiving processing engine; The scene online and offline configuration information is determined based on an event dispatcher, and includes: Obtain the scene online and offline configuration information from the message transceiving processing engine; the scene online and offline configuration information is determined based on a virtual signal bus converting configuration signals into semaphores, the virtual signal bus is implemented based on the function of the event dispatcher; the configuration signals are determined based on the event dispatcher analyzing scene online and offline events; the scene online and offline events are determined based on an external event sensor.

7. A dynamic message routing apparatus implemented using the dynamic message routing method according to any one of claims 1 to 6, characterized by, The device includes: A first obtaining module is configured to obtain first target information corresponding to a target message collector in a message transceiving processing engine from a message processing center in the message transceiving processing engine; the first target information is transmitted to the message processing center by the target message collector, and the target message collector is a message collector that has listened to an initial message; A second obtaining module is configured to query information corresponding to the first target information to obtain second target information; An information processing module is configured to send the second target information to the message processing center, so that the message processing center determines a target message transmitter corresponding to the second target information in the message transceiving processing engine based on the second target information to obtain target corresponding information; and so that the message processing center sends the target corresponding information to the target message collector, so that the target message collector transmits the initial message to the target message transmitter based on the target corresponding information; and so that the target message transmitter sends the initial message to the message processing center for processing to obtain a target message; and so that the message processing center sends the target message to the target message transmitter, so that the target message transmitter sends the target message to an external message collector.

8. An electronic device, comprising: A computer readable storage medium, the storage medium storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the dynamic message routing method according to any one of claims 1 to 6.

9. A computer readable storage medium, the storage medium storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the dynamic message routing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Business processing system, business processing method and related device

    CN113535253A

  • Monitoring data processing method and device and computer readable storage medium

    CN114785722A