Gateway message interaction system
By introducing the message transmission channel of the event bus interaction component and the message forwarding component into the gateway message interaction system, the message interaction of each module is decoupled, which solves the problem of low efficiency of gateway message interaction and realizes efficient message transmission on different hardware platforms.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QINGDAO HAIER TECH
- Filing Date
- 2023-06-29
- Publication Date
- 2026-06-23
AI Technical Summary
In existing technologies, gateway message interaction is inefficient, especially on hardware platforms with poor resource performance, and message consumption requires multiple layers of interfaces, resulting in high time consumption.
A gateway message interaction system is adopted, including a first service gateway and a second service gateway. Through the message transmission channel between the first event bus interaction component and the first message forwarding component, it responds to subscription requests and transmits different types of gateway messages, thus decoupling the message interaction of each module.
It improves the efficiency of gateway message interaction, adapts to different hardware platforms, reduces message transmission time, and enhances system performance.
Smart Images

Figure CN116743691B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart home technology, and more specifically, to a gateway message interaction system. Background Technology
[0002] Currently, edge scenario service architectures are typically built using a centralized single-host architecture. This type of service architecture, such as... Figure 1 As shown, it relies on the hardware resource performance of a single host and cannot be adapted to hardware platforms with poor resource performance. Furthermore, since each interface can only communicate through a pipe, each message consumption needs to go through multiple layers of interfaces, which is very time-consuming and results in very low efficiency of gateway message interaction.
[0003] Therefore, in related technologies, there is a technical issue of how to improve the efficiency of gateway message interaction.
[0004] No effective solution has yet been proposed to address the technical challenge of improving the efficiency of gateway message interaction in related technologies. Summary of the Invention
[0005] This application provides a gateway message interaction system to at least solve the technical problem of how to improve the interaction efficiency of gateway messages in related technologies.
[0006] According to one embodiment of this application, a gateway message interaction system is provided, including: a first service gateway, and a second service gateway connected to the first service gateway; the first service gateway includes: a first event bus interaction component, and a first message forwarding component connected to the first event bus interaction component; wherein, a message transmission channel is established between the first message forwarding component and the first event bus interaction component; the first event bus interaction component is used to respond to a first subscription request from the first message forwarding component and send gateway messages of different message types stored in the first event bus interaction component to the first message forwarding component; the first message forwarding component is used to receive a second subscription request sent by the second service gateway, determine a gateway message of a first message type indicated by the second subscription request from the received gateway messages of different message types, and send the gateway message of the first message type indicated by the second subscription request to the second service gateway.
[0007] In an exemplary embodiment, the first event bus interaction component is further configured to respond to a third subscription request sent by other components, determine the gateway message corresponding to the second message type indicated by the third subscription request from gateway messages of different message types stored in the first event bus interaction component, and send the gateway message corresponding to the second message type to the other components, wherein the other components are components in the first service gateway other than the first event bus interaction component.
[0008] In one exemplary embodiment, the other components further include: a first user-side service module connected to the first event bus interaction component, wherein the first user-side service module is configured to obtain a gateway message with a preset format from the first event bus interaction component, encapsulate the gateway message with the preset format to obtain an encapsulated message function, so that any component included in the first service gateway can obtain the gateway message with the preset format by calling the function interface of the message function.
[0009] In one exemplary embodiment, the other components further include: a first user-side service module connected to the first event bus interaction component, wherein the first event bus interaction component is further configured to, in response to a fourth subscription request sent by the first user-side service module, send a first gateway message corresponding to the device state indicated by the fourth subscription request to the first user-side service module; wherein the first user-side service module is configured to monitor a first message flag in the first event bus interaction component, and send the fourth subscription request to the first event bus interaction component when the first message flag indicates that the first gateway message corresponding to the device state has changed.
[0010] In one exemplary embodiment, the other components further include: a first domain model component connected to the first event bus interaction component, wherein the first domain model component is configured to obtain a first gateway message corresponding to a device state from the first event bus interaction component, generate a second gateway message corresponding to a domain state based on the first gateway message, and send the second gateway message to the first event bus interaction component.
[0011] In one exemplary embodiment, the other components further include: a first domain model component connected to the first event bus interaction component, the first event bus interaction component being further configured to perform one of the following: in response to a fourth subscription request sent by the first domain model component, sending a first gateway message corresponding to a device state indicated by the fourth subscription request to the first domain model component; in response to a fifth subscription request sent by the first domain model component, sending a third gateway message corresponding to a scene state indicated by the fifth subscription request to the first domain model component.
[0012] In one exemplary embodiment, the other components further include: a first scene software development kit component connected to the first event bus interaction component, wherein the first scene software development kit component is configured to send a pre-stored third gateway message corresponding to the scene state to the first event bus interaction component.
[0013] In one exemplary embodiment, the other components further include: a first gateway message filter connected to the first event bus interaction component, configured to receive an operation instruction from a target object, filter the initial gateway message in the operation instruction to obtain a gateway message that meets the desired conditions, convert the message format of the gateway message that meets the desired conditions into a preset format to obtain a gateway message with the preset format, and send the gateway message with the preset format to the first event bus interaction component.
[0014] In one exemplary embodiment, the second service gateway includes: a second event bus interaction component, a first message forwarding component, and is further configured to obtain gateway messages of different message types from the first event bus interaction component, and respond to a sixth subscription request sent by the second event bus interaction component by sending gateway messages of different message types indicated by the sixth subscription request to the second event bus interaction component.
[0015] In one exemplary embodiment, the other components further include: a first memory load calculation component connected to the first event bus interaction component, and a first scenario software development kit component connected to the first event bus interaction component, wherein the first memory load calculation component is configured to send a fourth gateway message corresponding to the detected memory state to the first event bus interaction component; the first event bus interaction component is further configured to respond to a seventh subscription request sent by the first scenario software development kit component and send the fourth gateway message corresponding to the memory state indicated by the seventh subscription request to the first scenario software development kit component.
[0016] The gateway message interaction system proposed in this application includes a first service gateway and a second service gateway connected to the first service gateway. The first service gateway includes a first event bus interaction component and a first message forwarding component connected to the first event bus interaction component. A message transmission channel is established between the first message forwarding component and the first event bus interaction component. The first event bus interaction component is used to respond to a first subscription request from the first message forwarding component and send gateway messages of different message types stored in the first event bus interaction component to the first message forwarding component. The first message forwarding component is used to receive a second subscription request from the second service gateway, determine the gateway message of the first message type indicated by the second subscription request from the received gateway messages of different message types, and send the gateway message of the first message type indicated by the second subscription request to the second service gateway. The gateway message interaction system provided by the above technical solution solves the technical problem of how to improve the interaction efficiency of gateway messages in related technologies, thereby improving the interaction efficiency of gateway messages. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram of the overall framework of a single gateway in related technologies;
[0020] Figure 2 This is a schematic diagram illustrating the principle of a gateway message interaction process according to an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of the structure of a gateway message interaction system according to an embodiment of this application;
[0022] Figure 4 This is a schematic diagram (a) of the interaction flow of a gateway message according to an embodiment of this application;
[0023] Figure 5 This is a schematic diagram (II) of the interaction flow of a gateway message according to an embodiment of this application;
[0024] Figure 6This is a schematic diagram (III) of a gateway message interaction process according to an embodiment of this application. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application 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. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] This application provides a gateway message interaction system. This gateway message interaction system is widely used in whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the structure of the aforementioned gateway message interaction system is as follows: Figure 2 As shown, Figure 2 This is a schematic diagram illustrating the principle of a gateway message interaction process according to an embodiment of this application. Figure 2 The system includes a first service gateway 22 and a second service gateway 24 connected to the first service gateway. This application does not limit the number of first service gateways 22 and second service gateways 24.
[0028] The first service gateway 22 includes: a first event bus interaction component and a first message forwarding component connected to the first event bus interaction component. A message transmission channel is established between the first message forwarding component and the first event bus interaction component, allowing them to transmit messages via this channel. For example, the first event bus interaction component may respond to a first subscription request from the first message forwarding component by sending gateway messages of different message types stored in the first event bus interaction component to the first message forwarding component.
[0029] The first message forwarding component is configured to receive a second subscription request sent by the second service gateway 24, determine the gateway message of the first message type indicated by the second subscription request from the received gateway messages of different message types, and send the gateway message of the first message type indicated by the second subscription request to the second service gateway.
[0030] It should be noted that the gateway messages of the different message types mentioned above may include, for example, a first gateway message corresponding to the device status, a second gateway message corresponding to the domain status, a third gateway message corresponding to the scene status, and a fourth gateway message corresponding to the memory status.
[0031] For example, the first gateway message corresponding to the device status can be represented as the " / user / gatewayid / data" topic message, which includes the original basic messages such as device online / offline / binding / unbinding / subscription / unsubscription / attributes / alarms / event control.
[0032] The second gateway message corresponding to the domain state can be represented as the " / user / gatewayid / dm_data" topic message, including shadow device initialization messages, attribute / alarm message notifications, batch control command messages, domain model point-marking messages, and domain model whitelist messages.
[0033] The third gateway message corresponding to the scene status can be represented as the " / user / gatewayid / scene_data" topic message, including messages such as scene batch control command subscription, SDL device-side messages, and scene tracking messages.
[0034] The fourth gateway message corresponding to the memory status can be represented as the " / user / gatewayid / cpuload_data" topic message, which includes the CPU load status of the gateway device and the IP information of the local area network gateway.
[0035] Optionally, the aforementioned gateway message interaction system can be applied to different networks, including but not limited to at least one of the following: wired network and wireless network. The aforementioned wired network can include but is not limited to at least one of the following: wide area network (WAN), metropolitan area network (MAN), and local area network (LAN). The aforementioned wireless network can include but is not limited to at least one of the following: Wi-Fi (Wireless Fidelity) and Bluetooth. Furthermore, the terminal devices corresponding to the aforementioned first service gateway 22 and / or second service gateway 24 are not limited to PCs, mobile phones, tablets, smart air conditioners, smart range hoods, smart refrigerators, smart ovens, smart stoves, smart washing machines, smart water heaters, smart washing equipment, smart dishwashers, smart projectors, smart TVs, smart clothes racks, smart curtains, smart audio-visual equipment, smart sockets, smart speakers, smart speakers, smart fresh air systems, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaners, smart window cleaning robots, smart mopping robots, smart air purifiers, smart steam ovens, smart microwave ovens, smart water heaters, smart air purifiers, smart water dispensers, smart door locks, etc.
[0036] In the above embodiments, a gateway message interaction system is provided, comprising a first service gateway and a second service gateway connected to the first service gateway. This system improves the efficiency of gateway message interaction by having a first event bus interaction component included in the first service gateway respond to a first subscription request from the first message forwarding component and send gateway messages of different message types stored in the first event bus interaction component to the first message forwarding component. Alternatively, the first message forwarding component can receive a second subscription request from the second service gateway, determine the gateway message of the first message type indicated by the second subscription request from the received gateway messages of different message types, and send the gateway message of the first message type indicated by the second subscription request to the second service gateway. By deploying an event bus interaction component within the gateway to achieve message interaction between various modules, the messages and services of each module can be decoupled. Furthermore, the gateway message interaction system of the above embodiments solves the technical problem of how to improve the interaction efficiency of gateway messages in related technologies, thereby improving the interaction efficiency of gateway messages.
[0037] In an exemplary embodiment, the first event bus interaction component is further configured to respond to a third subscription request sent by other components, determine the gateway message corresponding to the second message type indicated by the third subscription request from the gateway messages of different message types stored in the first event bus interaction component, and send the gateway message corresponding to the second message type to the other components, wherein the other components are components in the first service gateway other than the first event bus interaction component.
[0038] In one exemplary embodiment, the other components further include: a first user-side service module connected to the first event bus interaction component, wherein the first user-side service module is configured to obtain a gateway message with a preset format from the first event bus interaction component, encapsulate the gateway message with the preset format to obtain an encapsulated message function, so that any component included in the first service gateway can obtain the gateway message with the preset format by calling the function interface of the message function.
[0039] In one exemplary embodiment, the other components further include: a first user-side service module connected to the first event bus interaction component, wherein the first event bus interaction component is further configured to, in response to a fourth subscription request sent by the first user-side service module, send a first gateway message corresponding to the device state indicated by the fourth subscription request to the first user-side service module; wherein the first user-side service module is configured to monitor a first message flag in the first event bus interaction component, and send the fourth subscription request to the first event bus interaction component when the first message flag indicates that the first gateway message corresponding to the device state has changed.
[0040] In one exemplary embodiment, the other components further include: a first domain model component connected to the first event bus interaction component, wherein the first domain model component is configured to obtain a first gateway message corresponding to the device state from the first event bus interaction component, generate a second gateway message corresponding to the domain state based on the first gateway message, and send the second gateway message to the first event bus interaction component.
[0041] The second gateway message mentioned above can be generated based on the physical address contained in the first gateway message, and the first gateway message and the second gateway message correspond to the same physical address.
[0042] In one exemplary embodiment, the other components further include: a first domain model component connected to the first event bus interaction component, wherein the first event bus interaction component is further configured to perform one of the following: in response to a fourth subscription request sent by the first domain model component, sending a first gateway message corresponding to the device state indicated by the fourth subscription request to the first domain model component; in response to a fifth subscription request sent by the first domain model component, sending a third gateway message corresponding to the scene state indicated by the fifth subscription request to the first domain model component.
[0043] In one exemplary embodiment, the other components further include: a first scene software development kit component connected to the first event bus interaction component, wherein the first scene software development kit component is used to send a pre-stored third gateway message corresponding to the scene state to the first event bus interaction component.
[0044] In one exemplary embodiment, the other components further include: a first gateway message filter connected to the first event bus interaction component, configured to receive operation instructions from a target object, filter initial gateway messages in the operation instructions to obtain gateway messages that meet desired conditions, convert the message format of the gateway messages that meet desired conditions into a preset format to obtain gateway messages with a preset format, and send the gateway messages with a preset format to the first event bus interaction component.
[0045] In one exemplary embodiment, the second service gateway includes: a second event bus interaction component, the first message forwarding component, and is further configured to obtain gateway messages of different message types from the first event bus interaction component, and respond to a sixth subscription request sent by the second event bus interaction component, and send gateway messages of different message types indicated by the sixth subscription request to the second event bus interaction component.
[0046] It should be noted that the second business gateway has the same structure as the first business gateway and can achieve similar functions. For example, the second business gateway may include at least one of the following: a second user-side business module, a second event bus interaction component, a second domain model component, a second scenario software development kit component, a second memory load calculation component, a second gateway message filter, a second master-slave database backup component, and a second message forwarding component. The second message forwarding component is used to obtain gateway messages of different message types from the second event bus interaction component, and to respond to the subscription request sent by the first event bus interaction component of the first business gateway, and send the gateway messages of different message types indicated by the subscription request to the first event bus interaction component.
[0047] In one exemplary embodiment, the other components further include: a first memory load calculation component connected to the first event bus interaction component, and a first scenario software development kit component connected to the first event bus interaction component, wherein the first memory load calculation component is used to send a fourth gateway message corresponding to the detected memory state to the first event bus interaction component; the first event bus interaction component is further used to respond to a seventh subscription request sent by the first scenario software development kit component and send the fourth gateway message corresponding to the memory state indicated by the seventh subscription request to the first scenario software development kit component.
[0048] Optionally, the other components mentioned above also include: a first domain model component connected to the first event bus interaction component, and a first scene software development kit component connected to the first event bus interaction component. The first event bus interaction component is further configured to receive a second gateway message corresponding to the domain state sent by the first domain model component, respond to a first other subscription request sent by the first scene software development kit component, and send the second gateway message corresponding to the domain state indicated by the first other subscription request to the first scene software development kit component.
[0049] Optionally, the other components mentioned above also include: a first memory load calculation component connected to the first event bus interaction component, and a first domain model component connected to the first event bus interaction component, wherein the first memory load calculation component is used to send the detected fourth gateway message corresponding to the memory state to the first event bus interaction component; the first event bus interaction component is further used to, upon receiving the fourth gateway message corresponding to the memory state sent by the first memory load calculation component, respond to the second other subscription request sent by the first domain model component, and send the fourth gateway message corresponding to the memory state indicated by the second other subscription request to the first domain model component.
[0050] Optionally, the other components mentioned above also include: a first master-slave database backup component connected to the first event bus interaction component, and a first scenario software development kit component connected to the first event bus interaction component, wherein the first event bus interaction component is further configured to receive a fifth gateway message corresponding to the script state sent by the first scenario software development kit component, and respond to a third other subscription request sent by the first master-slave database backup component, and send the fifth gateway message corresponding to the script state indicated by the third other subscription request to the first master-slave database backup component.
[0051] In one embodiment, combined Figure 3 To provide a better explanation of the aforementioned gateway message interaction system, Figure 3 This is a schematic diagram of the structure of a gateway message interaction system according to an embodiment of this application. For example... Figure 3 As shown, the gateway message interaction system includes Gateway A (equivalent to the first service gateway mentioned above) and Gateway B (equivalent to the second service gateway mentioned above). Gateway A and Gateway B have the same composition structure, and each of Gateway A and Gateway B has a corresponding user service channel.
[0052] Taking Gateway A as an example, the interaction process of gateway messages is explained. The CAE sends messages transmitted via the user service channel to the UCOM component, which then forwards the messages to the gateway message filter (i.e., the first gateway message filter mentioned above). The gateway message filter sends the filtered messages to the event bus broker (equivalent to the event bus interaction component mentioned above). There is a message interaction process between the event bus broker and each of the following modules: the scenario JSDK (equivalent to the first scenario software development kit component mentioned above), the domain model (equivalent to the first domain model component mentioned above), the CPU load statistics module (equivalent to the first memory load calculation component mentioned above), the SDL user side (equivalent to the first user side business module mentioned above), the master-slave database backup module, and the message forwarding module (equivalent to the first message forwarding component mentioned above). In response to a subscription request from any of the following subscription sides—the gateway message filter, scenario JSDK, domain model, CPU load statistics module, SDL user side, master-slave database backup module, or message forwarding module—the event bus broker publishes the gateway message indicated by the subscription request to that subscription side.
[0053] Among them, Figure 3 In this context, SDL (Smart Device Linux SDK) refers to an IoT software development kit used by devices based on the Linux platform.
[0054] CAE (Computer-Aided Engineering) uses computer technology and software tools to simulate, analyze, and optimize physical phenomena, thereby helping designers improve product performance and reliability, reduce product development cycles and costs, and achieve intelligent and digital production. In gateway systems, CAE can also be used for network connectivity modeling and simulation analysis.
[0055] UCOM components refer to a general-purpose type library under COM (Component Object Model) technology, which includes some basic interface and structure definitions. These interfaces and structures allow developers to share code in different development environments, thereby achieving more efficient and reliable software development. UCOM components are commonly used on the Microsoft .NET platform, through which unmanaged code or COM components can be easily called, and objects written on the .NET platform can be interacted with.
[0056] An event bus broker is a component in a messaging framework used to pass messages between different parts of an application or system. It simplifies application development by decoupling publishers and subscribers and enabling asynchronous communication. In an event bus system, the event bus broker acts as a central node, serving as the interaction point for all publishing and receiving messages. The broker ensures messages are sent to the correct destinations, provides data control to connectors, and performs operations such as buffering events. This simplifies application integration, logging of processing tasks, and problem tracking.
[0057] The Scene JSDK (Java Software Development Kit) is a software development kit used to create and manage artificial intelligence scene models in a Java environment. It provides a rich set of APIs and tools, enabling developers to easily create, train, test, and deploy their own machine learning models. This SDK can be used with various third-party frameworks and libraries (such as TensorFlow, Keras, etc.) and supports local or cloud execution. By using the Scene JSDK, developers can quickly build high-quality AI applications for enterprise or individual users.
[0058] Furthermore, in one embodiment, a method for interacting with gateway messages is provided, such as... Figure 4 As shown, Figure 4 This is a schematic diagram (I) of a gateway message interaction process according to an embodiment of this application. The specific process is as follows:
[0059] Step S401: Gateway A's gateway message filter receives JSON messages from the CAE size loop, filters them to get the / user / gatewayid / basedata topic message, and sends the / user / gatewayid / basedata topic message to Gateway A's event soft bus broker (i.e., event bus broker);
[0060] Step S402: The domain model of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / data;
[0061] Step S403: In response to the subscription request in step S402, the event soft bus broker of gateway A pushes the topic message / user / gatewayid / data to the domain model of gateway A.
[0062] Step S404: The event soft bus broker of gateway A sends a subscription request to the SDL user side of gateway A to subscribe to the / user / gatewayid / data topic message;
[0063] Step S405: The CPU load statistics module of gateway A publishes a message with the topic / user / gatewayid / cpuload to the event soft bus broker of gateway A;
[0064] Step S406: The SDL user side of gateway A pushes the topic message / user / gatewayid / data to the event soft bus broker of gateway A;
[0065] Step S407: The domain model of gateway A publishes a message on the topic / user / gatewayid / dm_data to the event soft bus broker of gateway A;
[0066] Step S408: The scene JSDK of Gateway A publishes the topic message / user / gatewayid / scene_data to the event soft bus broker of Gateway A;
[0067] Step S409: The domain model of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / scene_data;
[0068] Step S410: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / scene_data to the domain model of gateway A;
[0069] Step S411: The scenario JSDK of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / dm_data;
[0070] Step S412: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / dm_data to the scenario JSDK of gateway A;
[0071] Step S413: The scenario JSDK of Gateway A publishes a message on the topic / user / gatewayid / base_data to the event soft bus broker of Gateway A;
[0072] Step S414: The master-slave database backup module of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the / user / gatewayid / basedata topic message;
[0073] Step S415: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / basedata to the master-slave database backup module of gateway A;
[0074] Step S416: The message forwarding module of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the / user / gatewayid / basedata topic message;
[0075] Step S417: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / basedata to the message forwarding module of gateway A;
[0076] Step S418: The message forwarding module of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / scene_data;
[0077] Step S419: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / scene_data to the message forwarding module of gateway A;
[0078] Step S420: The message forwarding module of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / dm_data;
[0079] Step S421: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / dm_data to the message forwarding module of gateway A;
[0080] It should be noted that the interaction processes in steps S401 to S421 are all message interaction processes within gateway A.
[0081] Step S422: The message forwarding module of gateway A sends a subscription request to the event soft bus broker of gateway B to subscribe to the / user / gatewayid / basedata topic message;
[0082] Step S423: The event soft bus broker of gateway B pushes the topic message / user / gatewayid / basedata to the message forwarding module of gateway A;
[0083] Step S424: The message forwarding module of Gateway A publishes a message on the topic / user / gatewayid / basedata to the event soft bus broker of Gateway A;
[0084] Step S425: The message forwarding module of gateway A sends a subscription request to the event soft bus broker of gateway B to subscribe to the / user / gatewayid / dm_data topic message;
[0085] Step S426: The event soft bus broker of gateway B pushes the topic message / user / gatewayid / dm_data to the message forwarding module of gateway A;
[0086] Step S427: The message forwarding module of Gateway A publishes a message on the topic / user / gatewayid / dm_data to the event soft bus broker of Gateway A;
[0087] Step S428: The message forwarding module of gateway A sends a subscription request to the event soft bus broker of gateway B to subscribe to the topic message / user / gatewayid / scene_data;
[0088] Step S429: The event soft bus broker of gateway B pushes the topic message / user / gatewayid / scene_data to the message forwarding module of gateway A;
[0089] Step S430: The message forwarding module of Gateway A publishes the topic message / user / gatewayid / scenedata to the event soft bus broker of Gateway A;
[0090] Step S431: The message forwarding module of gateway A sends a subscription request to the event soft bus broker of gateway B to subscribe to the / user / gatewayid / cpuload topic message;
[0091] Step S432: The event soft bus broker of gateway B pushes the topic message / user / gatewayid / cpuload to the message forwarding module of gateway A;
[0092] Step S433: The message forwarding module of gateway A publishes the topic message / user / gatewayid / cpuload to the event soft bus broker of gateway A;
[0093] Step S434: The domain model of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the / user / gatewayid / cpuload topic message;
[0094] Step S435: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / cpuload to the domain model of gateway A;
[0095] Step S436: The scenario JSDK of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the / user / gatewayid / cpuload topic message;
[0096] Step S437: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / cpuload to the scenario JSDK of gateway A.
[0097] Through the above steps, steps S401 to S421 describe the message interaction process within a single gateway, and steps S422 to S437 describe the message interaction process between different gateways, thus providing an implementation process for gateway message interaction.
[0098] Furthermore, taking gateway A as an example, the gateway message interaction process within gateway A will be explained. Within gateway A, messages are transmitted via the event soft bus. As shown in Table 1 below, the SDL user-side business module (i.e., SDL user side), the scenario JSDK business module (i.e., scenario JSDK), the domain model business module (i.e., domain model), and the master-slave database backup module all consume messages from each end by subscribing to event soft bus message topics.
[0099] Table 1 Module Data Table
[0100]
[0101] In one embodiment, the master-slave backup database component is used to back up the scenario engine rules and related business data of the local gateway and the same information of other gateways within the local area network. When a gateway has no external network access, it publishes a topic request message to the peer gateway broker within the local area network, and the peer returns the backed-up database to the requester. For example, if the database file of gateway A is corrupted, the scenario jsdk can publish the topic / user / gatewayid / basedata (database name). If gateway B subscribes to the / user / gatewayid / basedata topic message, it can consume the database backup requests from all gateways and return the backup to the requester based on the requested gateway ID.
[0102] Specifically, it can be combined with Figure 5 This paper describes the gateway message interaction process implemented based on the master-slave backup database component. Figure 5This is a schematic diagram (II) of a gateway message interaction process according to an embodiment of this application, as shown below. Figure 5 As shown, the specific steps are as follows:
[0103] Step S501: The master-slave database backup module of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the topic message / user / gatewayid / basedata;
[0104] Step S502: The master-slave database backup module of Gateway B sends a subscription request to the event soft bus broker of Gateway B to subscribe to the topic message / user / gatewayid / basedata;
[0105] Step S503: The scenario JSDK of Gateway A publishes a message on the topic / user / gatewayid / basedata to the event soft bus broker of Gateway A;
[0106] Step S504: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / basedata to the master-slave database backup module of gateway A;
[0107] Step S505: The gateway message forwarder component (i.e. message forwarding module) of gateway A sends a subscription request to the event soft bus broker of gateway A to subscribe to the / user / gatewayid / basedata topic message;
[0108] Step S506: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / basedata to the gateway message forwarder component of gateway A;
[0109] Step S507: The gateway message forwarder component of gateway A publishes a message on the topic / user / gatewayid / basedata to the event soft bus broker of gateway B;
[0110] Step S508: The event soft bus broker of Gateway B pushes the topic message / user / gatewayid / basedata to the master-slave database backup module of Gateway B.
[0111] By following the steps above, taking the / user / gatewayid / basedata topic message as an example, this paper explains the message interaction process between the master-slave database backup module and the event soft bus broker within a single gateway, as well as how different gateways can achieve message interaction based on the gateway message forwarder component. This can solve the problem that a gateway cannot achieve scene linkage due to file database corruption caused by power failure.
[0112] Furthermore, in one embodiment, the SDL user-side business module is used to subscribe to topic messages in ` / user / gatewayid / data`. It can encapsulate JSON-formatted messages into a function interface for use by the devapp caller. Therefore, the SDL user side does not need to directly interface with CAE messages; instead, it achieves independent decoupling of business processes by subscribing to gateway messages published to the event soft bus via the gateway filter. Specifically, taking gateway A as an example, it can be combined with... Figure 6 The interaction process of gateway messages in the SDL user-side component is described. Figure 6 This is a schematic diagram (III) of a gateway message interaction process according to an embodiment of this application, as shown below. Figure 6 As shown, the specific steps are as follows:
[0113] Step S601: The SDL user side of Gateway A sends a subscription request to the event soft bus broker of Gateway A to subscribe to the / user / gatewayid / data topic message;
[0114] Step S602: Gateway A's gateway message filter receives JSON messages from the CAE size loop through the / user / gatewayid / data topic message and publishes them to Gateway A's event soft bus broker;
[0115] Step S603: The event soft bus broker of gateway A pushes the topic message / user / gatewayid / data to the SDL user side of gateway A.
[0116] Optionally, in one embodiment, for each gateway, the CPU load rate of other gateways in the local area network to which each gateway belongs can be stored. The CPU load rate can be represented by the topic message ` / user / gatewayid / cpuload`. By subscribing to this topic message, the CPU load status of all gateways in the local area network can be obtained. For example, if the local area network includes gateway A, gateway B, gateway C, and gateway D, and if gateway A determines its CPU load rate to be 50% based on the topic message ` / user / gatewayid / cpuload`, and determines that gateways B, C, and D have CPU utilization rates of 20%, 30%, and 40% respectively, then gateway A's domain model module or gateway A's scenario JSDK module can split some gateway messages into smaller granular messages, process only the split messages, and distribute the remaining gateway messages to other gateways according to their CPU utilization rates.
[0117] Optionally, the scene JSDK module can also implement computing power distribution. Before each scene JSDK parses the scene script, it first queries the CPU load rate of each gateway in the local area network obtained from memory. If the CPU utilization of this gateway is less than 50%, it prioritizes parsing the local scene within this gateway (according to the original rules); otherwise, it selects the gateway with the lowest CPU utilization among other gateways in the local area network. In this way, monitoring the CPU load rate of each gateway can reasonably distribute the gateway messages corresponding to the business to the gateway servers on the other end for processing.
[0118] Optionally, any message forwarding module included in any gateway can establish a connection with the event soft bus broker based on an MQTT client and send subscription requests to all gateways within the local area network that are connected to the MQTT device server. For example, the message forwarding module of gateway A can send subscription requests to the event soft bus broker of gateway B for subscribing to messages on different topics, and vice versa.
[0119] Alternatively, when a change is detected in the gateway list within the local area network (including changes in gateway IPs and the number of gateways), a ` / user / gatewayid / gatewayinfo` topic message is sent to the event soft bus broker. The message forwarding module can then send a subscription request to the event soft bus broker to subscribe to the ` / user / gatewayid / gatewayinfo` topic message, thereby subscribing to the gateway IPs in the device list. The ` / user / gatewayid / gatewayinfo` topic message contains device ID information within the local area network, represented in JSON format as follows:
[0120] {"device_gateway_info": {"gatewayidMsgList": [{"deviceId": "F0B0402CB1E", "ip": "192.168.1.xxx"]}}.
[0121] Optionally, the gateway message filter can filter out irrelevant gateway messages and forward gateway messages that meet the expected conditions to the event soft bus broker. For example, each JSON-formatted gateway message corresponds to a pre-agreed message name, and the message filtering process can be implemented by matching message names using key-value pairs.
[0122] Based on the above embodiments, the problem of gateways being unable to perform scene linkage due to data loss caused by power outages or other reasons can be solved. Furthermore, the publish-subscribe process between the event bus broker and other modules, implemented using an event bus mechanism, can completely decouple messages and business logic, reducing the probability of message blocking and thus reducing the time consumption caused by multi-layered message interactions between modules. Additionally, it can monitor the CPU load of each gateway and distribute business processing to the gateway server on the other end.
[0123] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0124] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0125] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0126] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A gateway message interaction system, characterized in that, include: A first service gateway, and a second service gateway connected to the first service gateway; The first service gateway includes: a first event bus interaction component, and a first message forwarding component connected to the first event bus interaction component; wherein, a message transmission channel is established between the first message forwarding component and the first event bus interaction component; The first event bus interaction component is used to respond to the first subscription request of the first message forwarding component and send gateway messages of different message types stored in the first event bus interaction component to the first message forwarding component; The first message forwarding component is configured to receive a second subscription request sent by the second service gateway, determine the gateway message of the first message type indicated by the second subscription request from the received gateway messages of different message types, and send the gateway message of the first message type indicated by the second subscription request to the second service gateway. The first event bus interaction component is further configured to respond to a third subscription request sent by other components, determine the gateway message corresponding to the second message type indicated by the third subscription request from the gateway messages of different message types stored in the first event bus interaction component, and send the gateway message corresponding to the second message type to the other components, wherein the other components are components in the first service gateway other than the first event bus interaction component; The other components also include: a first domain model component connected to the first event bus interaction component, wherein the first domain model component is used to obtain a first gateway message corresponding to the device state from the first event bus interaction component, generate a second gateway message corresponding to the domain state based on the first gateway message, and send the second gateway message to the first event bus interaction component.
2. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first user-side service module connected to the first event bus interaction component, wherein the first user-side service module is used to obtain a gateway message with a preset format from the first event bus interaction component, encapsulate the gateway message with the preset format to obtain an encapsulated message function, so that any component included in the first service gateway can obtain the gateway message with the preset format by calling the function interface of the message function.
3. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first user-side service module connected to the first event bus interaction component, wherein the first event bus interaction component is further configured to, in response to a fourth subscription request sent by the first user-side service module, send a first gateway message corresponding to the device state indicated by the fourth subscription request to the first user-side service module; wherein the first user-side service module is configured to monitor a first message flag in the first event bus interaction component, and send the fourth subscription request to the first event bus interaction component when the first message flag indicates that the first gateway message corresponding to the device state has changed.
4. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first domain model component connected to the first event bus interaction component, the first event bus interaction component being further configured to perform one of the following: responding to a fourth subscription request sent by the first domain model component, sending a first gateway message corresponding to the device state indicated by the fourth subscription request to the first domain model component; responding to a fifth subscription request sent by the first domain model component, sending a third gateway message corresponding to the scene state indicated by the fifth subscription request to the first domain model component.
5. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first scene software development kit component connected to the first event bus interaction component, wherein the first scene software development kit component is used to send a pre-stored third gateway message corresponding to the scene state to the first event bus interaction component.
6. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first gateway message filter connected to the first event bus interaction component, used to receive operation instructions from the target object, filter the initial gateway messages in the operation instructions to obtain gateway messages that meet the expected conditions, convert the message format of the gateway messages that meet the expected conditions into a preset format to obtain gateway messages with the preset format, and send the gateway messages with the preset format to the first event bus interaction component.
7. The gateway message interaction system according to claim 1, characterized in that, The second service gateway includes: a second event bus interaction component, a first message forwarding component, and is further configured to obtain gateway messages of different message types from the first event bus interaction component, and respond to a sixth subscription request sent by the second event bus interaction component by sending gateway messages of different message types indicated by the sixth subscription request to the second event bus interaction component.
8. The gateway message interaction system according to claim 1, characterized in that, The other components also include: a first memory load calculation component connected to the first event bus interaction component, and a first scenario software development kit component connected to the first event bus interaction component, wherein the first memory load calculation component is used to send the detected fourth gateway message corresponding to the memory state to the first event bus interaction component; the first event bus interaction component is also used to respond to the seventh subscription request sent by the first scenario software development kit component and send the fourth gateway message corresponding to the memory state indicated by the seventh subscription request to the first scenario software development kit component.