CN115766314A - Method and device for transmitting messages among components, storage medium and electronic device - Google Patents

Method and device for transmitting messages among components, storage medium and electronic device Download PDF

Info

Publication number
CN115766314A
CN115766314A CN202211349243.7A CN202211349243A CN115766314A CN 115766314 A CN115766314 A CN 115766314A CN 202211349243 A CN202211349243 A CN 202211349243A CN 115766314 A CN115766314 A CN 115766314A
Authority
CN
China
Prior art keywords
message
target
subscription
information
storage unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211349243.7A
Other languages
Chinese (zh)
Inventor
魏志远
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Haier Uplus Intelligent Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd, Haier Uplus Intelligent Technology Beijing Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202211349243.7A priority Critical patent/CN115766314A/en
Priority to PCT/CN2022/135688 priority patent/WO2024092939A1/en
Publication of CN115766314A publication Critical patent/CN115766314A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a method and a device for message transmission among components, a storage medium and an electronic device, which relate to the technical field of smart home, wherein the method comprises the following steps: acquiring a target message issued by a message issuing component of target equipment through a message transmitting component of the target equipment, wherein the message transmitting component is used for transmitting messages among different components of the target equipment, and the target message is identified through a target message identifier; searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; and when the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table, transmitting the target message to the message subscription component corresponding to the subscription information stored in the target storage unit.

Description

Method and device for transmitting messages among components, storage medium and electronic device
Technical Field
The application relates to the technical field of smart home/smart home, in particular to a method and a device for message transmission between components, a storage medium and an electronic device.
Background
In the field of embedded systems, in order to facilitate message passing between different components in the system, distribution and passing of messages can be performed based on a subscription publishing manner. A message subscriber (i.e., a message receiving end, a component for receiving a message) can subscribe to a message through a message identifier, and multiple message subscribers can subscribe to a message identified by the same message identifier.
In the related art, subscription information corresponding to a message subscriber may be stored in a subscription table, and a message identifier and subscription information corresponding to a message subscriber that subscribes to a message identified by the message identifier are recorded in the subscription table. However, in the above storage manner of the subscription information, the memory resource occupied by the subscription table is large. When the message is transmitted between the components, the required subscription information can be determined only by traversing all the subscription information in the subscription table, and the information acquisition efficiency is low.
Therefore, in the message transmission mode among the components in the related art, the problem of low information acquisition efficiency caused by large storage resources occupied by the subscription table exists.
Disclosure of Invention
The embodiment of the application provides a method and a device for message transmission among components, a storage medium and an electronic device, which at least solve the problem that the message transmission mode among the components in the related art has lower information acquisition efficiency due to larger storage resources occupied by a subscription table.
According to an aspect of an embodiment of the present application, there is provided a method for message passing between components, including: acquiring a target message published by a message publishing component of a target device through a message transmitting component of the target device, wherein the message transmitting component is used for transmitting messages among different components of the target device, and the target message is identified by a target message identifier; responding to the acquired target message, searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; and under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, transmitting the target message to a message subscription component corresponding to the subscription information stored in the target storage unit.
According to another aspect of the embodiments of the present application, there is also provided an inter-component messaging apparatus, including: a first obtaining unit, configured to obtain, by a message passing component of a target device, a target message published by a message publishing component of the target device, where the message passing component is configured to pass messages between different components of the target device, and the target message is a message identified by a target message identifier; the searching unit is used for responding to the acquired target message and searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; and the delivery unit is used for delivering the target message to the message subscription component corresponding to the subscription information stored in the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table.
According to another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the above-mentioned inter-component message passing method when running.
According to another aspect of the embodiments of the present application, there is provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-mentioned message passing method between components by using the computer program.
In the embodiment of the application, a mapping relation between a message identifier of a subscribed message and a memory address of an information storage unit corresponding to component information is recorded in a subscription table, and a target message published by a message publishing component of a target device is acquired through a message transmitting component of the target device, wherein the message transmitting component is used for transmitting messages among different components of the target device, and the target message is a message identified by the target message identifier; responding to the acquired target message, and searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; the method comprises the steps that under the condition that the memory address of a target storage unit corresponding to a target message identifier is found in a subscription table, a target message is transmitted to a message subscription component corresponding to subscription information stored in the target storage unit, the information stored in the subscription table is only the mapping relation between the memory address of the storage unit of the component information of the subscription message and the message identifier of the subscribed message, the storage resource occupied by the subscription table is small, the memory address of the storage unit corresponding to the message identifier is found through the mapping relation stored in the subscription table before the message is distributed, whether the component subscribing the published message exists or not can be determined, the purpose of reducing the storage resource occupied by the subscription table can be achieved, the technical effect of improving the information acquisition efficiency is achieved, and the problem that the information acquisition efficiency is low due to the fact that the storage resource occupied by the subscription table is large in the message transmission mode among the components in the related technology is solved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 is a hardware environment diagram of a method for inter-component messaging according to an embodiment of the present application;
FIG. 2 is a flow diagram illustrating an alternative inter-component messaging method according to an embodiment of the present application;
FIG. 3 is a flow diagram illustrating an alternative inter-component messaging method according to an embodiment of the present application;
FIG. 4 is a block diagram of an alternative inter-component messaging apparatus according to an embodiment of the present application;
fig. 5 is a block diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be implemented in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to one aspect of an embodiment of the present application, a method for inter-component messaging is provided. The message passing method among the components is widely applied to full-House intelligent digital control application scenes such as intelligent homes (Smart Home), intelligent homes, intelligent Home equipment ecology, intelligent House (Intelligent House) ecology and the like. Alternatively, in this embodiment, the above-described message passing method between components may be applied to a hardware environment formed by the terminal device 102 and the server 104 as shown in fig. 1. As shown in fig. 1, the server 104 is connected to the terminal device 102 through a network, and may be configured to provide a service (e.g., an application service) for the terminal or a client installed on the terminal, provide a database on or independent of the server for providing a data storage service for the server 104, and configure a cloud computing and/or edge computing service on or independent of the server for providing a data operation service for the server 104.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity ), bluetooth. Terminal equipment 102 can be but not limited to be PC, the cell-phone, the panel computer, intelligent air conditioner, intelligent cigarette machine, intelligent refrigerator, intelligent oven, intelligent kitchen range, intelligent washing machine, intelligent water heater, intelligent washing equipment, intelligent dish washer, intelligent projection equipment, intelligent TV, intelligent clothes hanger, intelligent (window) curtain, intelligence audio-visual, smart jack, intelligent stereo set, intelligent audio amplifier, intelligent new trend equipment, intelligent kitchen guarding equipment, intelligent bathroom equipment, intelligence robot of sweeping the floor, intelligence robot of wiping the window, intelligence robot of mopping the ground, intelligent air purification equipment, intelligent steam ager, intelligent microwave oven, intelligent kitchen is precious, intelligent clarifier, intelligent water dispenser, intelligent lock etc. can carry out voice interaction's speech equipment.
The message passing method between the components in the embodiment of the present application may be executed by the server 104, or executed by the terminal device 102, or executed by both the server 104 and the terminal device 102. The terminal device 102 may execute the inter-component message passing method according to the embodiment of the present application by a client installed thereon.
Taking the terminal device 102 as an example to execute the inter-component message passing method in this embodiment, fig. 2 is a schematic flow chart of an optional inter-component message passing method according to the embodiment of the present application, and as shown in fig. 2, the flow chart of the method may include the following steps:
step S202, a target message published by a message publishing component of the target device is obtained through a message transferring component of the target device, where the message transferring component is used to transfer messages between different components of the target device, and the target message is a message identified by a target message identifier.
The inter-component message delivery method in this embodiment may be applied to a scenario where a message delivery component inside a device of a target device completes message distribution through a subscription table. The operating system running on the target device may be an operating system in the field of embedded systems, for example, an ecological operating system of a smart home in the field of smart home. The embedded system can comprise a hardware part and a software part, and the operating system in the embedded system can have the core function of a common operating system and is responsible for the allocation of all software and hardware resources of the embedded system, the control of scheduling work and the coordination of concurrent activities. The target device can be an intelligent household device or other types of terminal devices.
In the field of embedded systems, in order to implement message transmission between a message sending end and a message receiving end in a target device, a message proxy end may be set, which may obtain a message sent (i.e., published) by the message sending end from a message publishing end and transmit the obtained message to the message receiving end, and the message sending end and the message receiving end may only concern an interface corresponding to the message proxy end. Here, the message broker may distribute and deliver the message based on a subscription and publication manner, and the message broker may obtain the message published by the message sender and distribute the obtained message to the message receiver subscribed with the message. Correspondingly, a message sender may be a message publisher of a particular message type, and may be referred to as a message publishing component, publisher, etc. The message receiving end may be a subscriber of a particular message type and may be referred to as a message subscribing component, subscriber, etc. The message broker is also referred to as a messaging component, a publish-subscribe component, and the like.
It should be noted that the message receiving end may be an independent component, or may be a component depending on a certain RTE Environment (Run-Time Environment), where the RTE Environment refers to a specific and independent context Environment in which a section of code is to be executed, and is equivalent to an independent thread. A messaging component is a component distinct from both a message originator and a message recipient. When the message agent is published and the message published to the message transmission assembly is obtained, the message transmission assembly can retrieve the message type and send the message type to the process executed by the RTE environment, and if the RTE environment does not exist, the process of the callback function registered by the message receiving end can be directly executed. When the message is distributed in the system, the message publishing terminal can execute the action of publishing the message by calling the message publishing interface provided by the publish-subscribe component and publish the message to be published to the message delivery component, and the message delivery component finishes the distribution and message delivery processes.
In this embodiment, in the target device, after the message publishing component serves as a message publishing end to publish the target message to the message passing component, the message passing component may obtain the target message published by the message publishing component. Wherein the target message can be published to the messaging component by the message publishing component by invoking a message publishing interface of the messaging component. Here, the target message may be identified by a target message identifier, may be a message of a specific message type issued by the message issuing component, and may be used to trigger the message receiving component to execute a corresponding service. The target message identifier may be an identifier (Identity document) of the target message, and the message ID may be a message event number (msg _ ID) defined according to specific service logic needs, and may be defined according to the specific service logic needs, where the message passing component may be used to pass messages between different components of the target device.
Step S204, responding to the acquired target message, searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message.
The message subscription component of the target device can ensure timely receipt of the message by subscribing to the message in advance through the message identifier. Different message subscription components can subscribe to the same message identified by the message identification using the same message identification, and the same message subscription component can subscribe to different messages through different message identifications or different subscription parameters. Subscription information corresponding to the message subscription component may be stored in the form of a subscription table. The subscription table can be used for recording a mapping relationship between the message identification of the subscribed message and subscription information corresponding to the message subscription component subscribed to the subscribed message. The subscription table can be stored in the memory, so that the subscription information can be stored and managed by directly operating the memory, and compared with the method of storing and managing the subscription information by a database, the speed of acquiring the subscription information is higher, and the occupied resources are smaller.
If the message identified by one message identifier only has one message subscription component, the subscription table can be recorded and managed in a simple kv (key-value) data management manner, where a key is the message identifier (i.e., msg _ id), and a value is a memory address of subscription information corresponding to the message subscription component. However, there are typically multiple messages and multiple message subscription components in the target device at the same time, a message identified by one message identifier is not usually a single message subscription component, but there are multiple message subscription components, and the same message subscription component may subscribe to multiple messages through one or more message identifiers. For the situation that the same message subscription component subscribes to a plurality of messages and the same message is subscribed by a plurality of message subscription components, the storage mode of the subscription information is adopted, the storage resource occupied by the subscription table of the target device is large, when the messages are transmitted among the components, all the subscription information in the subscription table needs to be traversed to determine all the subscription information, and through the mode of storing and managing the subscription information by the database, under the situation that the subscription information is more and complicated, the subscription table needs to occupy a large memory, and the information acquisition efficiency is low.
For example, the same msg _ id may be subscribed to by one or more subscribers. If there is only one subscriber. Management can be achieved through a simple kv data management mode, namely, key is msg _ id, and value is a memory address of subscriber information. However, the subscribers of msg _ id are typically not single subscribers.
In order to at least partially solve the above problem, in this embodiment, subscription information corresponding to a message subscription component of a subscribed message may be stored in an information storage unit outside a subscription table, and only a mapping relationship between a message identifier of the subscribed message and a memory address of the information storage unit corresponding to the message identifier of the subscribed message is recorded in the subscription table, where memory resources occupied by the subscription table are small. When the message is transmitted among the components, whether the message subscription component subscribing the current message exists can be determined without spending longer time to traverse the subscription table; if the subscription information exists, the needed subscription information can be searched in the memory address of the information storage unit corresponding to the message identifier. Here, the information storage unit may be a storage structure of a type such as an information linked list. The information linked list may be a non-continuous, non-sequential storage structure in a physical storage space, and may be composed of a series of nodes (each element in the linked list is called a node or a node), and the nodes may be dynamically generated at runtime.
Optionally, the mapping relationship recorded in the subscription table may be a relationship obtained by performing mapping calculation on the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message. The mapping may be a hash mapping, and one object may be used to retrieve another object, the first object being a key and the second object being a value. In this embodiment, as shown in fig. 3, a message identifier may be used as a key, and a memory address of an information storage unit may be used as a value, for a case that one message has only one message subscription component, the subscription information may be managed in a kv data management manner on the right side in fig. 3, and for a case that one message has multiple message subscription components, the subscription information may be recorded in a manner that an information storage unit on the left side in fig. 3 manages the subscription information.
In this embodiment, in response to an acquired target message, the message delivery component may determine a target message identifier corresponding to the target message; and searching a subscription table according to the target message identification. If the mapping relationship between the target message identifier and the memory address of the information storage unit corresponding to the target message identifier is recorded in the subscription table, the memory address of the information storage unit corresponding to the target message identifier recorded in the subscription table can be determined. If the mapping relationship between the target message identifier and the memory address of the information storage unit corresponding to the target message identifier is not recorded in the subscription table, it can be determined that no message subscription component subscribes to the target message.
Step S206, when the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table, the target message is transmitted to the message subscription component corresponding to the subscription information stored in the target storage unit.
In this embodiment, if the mapping relationship between the target message identifier and the memory address of the information storage unit corresponding to the target message identifier is found in the subscription table, the information storage unit corresponding to the target message identifier may be located according to the found memory address. Because the information storage unit corresponding to the target message identifier stores the subscription information corresponding to the message subscription component for subscribing the target message only, the target message can be directly transmitted to the message subscription component corresponding to the subscription information stored in the target storage unit according to the subscription information in the information storage unit corresponding to the target message identifier. Here, the target storage unit may store subscription information corresponding to a message subscription component that subscribes to the target message.
For the case where multiple message subscription components subscribe to the target message, the messaging component can pass the target message to each message subscription component separately. The process of delivering the target message to different message subscription components may be executed in parallel, or may be executed in series (that is, the target message is sequentially delivered to each message subscription component).
Optionally, if the memory address of the target storage unit corresponding to the target message identifier is not found in the subscription table, it may be determined that the target message is not subscribed by any message subscription component temporarily, and the message delivery component may end the distribution operation on the target message.
It should be noted that, during message delivery, the message broker may deliver a message to be published (e.g., a target message) to the message subscriber by executing a callback function registered by the message subscriber. The callback function may be a message processing function, where the message processing function may be registered by the message subscriber when subscribing to the message, and the completion of the message processing function call may indicate that the message subscriber completes receiving and processing the message. Here, when the message broker issues a message, the message broker invokes the message processing function, and the relevant content of the message is transmitted to the function in the form of parameters; the internal processing of the function realizes that the message is acquired and corresponding service logic processing is carried out (which is equivalent to that the message is subjected to service processing according to the requirements of the message subscription end, namely, message transmission is realized). In addition, the message subscribing terminal can also define parameters of a message processing function and transmits the parameters when subscribing the message, so that the message transfer component can be called when transferring the message, and the special requirements of the message subscribing terminal are met.
Through the steps S202 to S206, the message passing component of the target device obtains a target message issued by the message issuing component of the target device, where the message passing component is used to pass messages between different components of the target device, and the target message is a message identified by a target message identifier; responding to the acquired target message, and searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, the target message is transmitted to the message subscription component corresponding to the subscription information stored in the target storage unit, so that the problem that the efficiency of information acquisition is low due to the fact that storage resources occupied by the subscription table are large in a message transmission mode among components in the related art is solved, and the efficiency of information acquisition is improved.
In an exemplary embodiment, when the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table, the method for delivering the target message to the message subscription component corresponding to the subscription information stored in the target storage unit includes:
s11, traversing each chain table node in the target information chain table according to the head address of the target information chain table under the condition that the head address of the target information chain table corresponding to the target message identifier is found in the subscription table, wherein subscription information corresponding to one message subscription component of the message identified by the target message identifier is stored in each chain table node;
and S12, transmitting the target message to a message subscription component corresponding to the subscription information stored in each traversed linked list node.
For the case that the information storage unit storing the subscription information is an information linked list, the mapping relationship recorded in the subscription table may be a mapping relationship between the message identifier of the subscribed message and the header address of the information linked list corresponding to the message identifier of the subscribed message, and the memory address of the information storage unit may be the header address of the information linked list. The information linked list can be a linked list circulating in two directions, and the head of the information linked list can be a head node.
In this embodiment, the target storage unit may be a target information linked list, and the memory address of the target storage unit is the header address of the target information linked list. And under the condition that the head address of the target information linked list corresponding to the target message identifier is found in the subscription table, traversing each linked list node in the target information linked list according to the head address of the target information linked list. Here, each linked list node may have stored therein subscription information corresponding to one message subscription component of the message identified by the target message identification.
Optionally, subscription information corresponding to all message subscription components of the message identified by the same message identifier (e.g., msg _ id) may be recorded by using one information link table, subscription information corresponding to one message subscription component of the message identified by the message identifier is stored in each link table node in the information link table, a memory address of a link table header of the information link table is used as a value and the message identifier for hash mapping, and an obtained mapping relationship is stored in the subscription table.
For each link table node in the traversed target information link table, the target message may be delivered to the message subscription component corresponding to the subscription information stored in each traversed information link table node according to the subscription information stored therein. The time for transferring the target message may be executed after the target information linked list is traversed, or may be executed after each link list node is traversed, and the distribution process may be the same as in the foregoing embodiment, which is not described in detail in this embodiment.
For example, in order to solve the problem that a plurality of subscriptions subscribe to the same msg _ id at the same time, a plurality of subscriber information subscribing to the same msg _ id (i.e., the above subscription information) may be managed by using a linked list, that is, as long as the subscriber information of the same msg _ id is all hung to the same linked list. Then, the address of the head of the chain table is used as value and msg _ id for carrying out hash mapping, and the obtained mapping relation is stored in a subscription table.
When the msg _ id is issued, whether the mapping relation of the chain table head exists in the subscription table can be searched according to the msg _ id, if so, the chain table is traversed, the issued message is distributed to all subscribers, and if the message is transmitted, the message can be transmitted through the parameter of the message processing function, so that the message transmission function can be realized. Here, the message processing function may be called by the message passing component to perform corresponding service logic processing. The parameters of the message handling function may be custom set by the message subscription component.
By the embodiment, the message subscription component information of the target message is determined by traversing the linked list storing the subscription information, so that the speed of acquiring the subscription information can be improved.
In an exemplary embodiment, the method further includes:
s21, acquiring a message subscription request of a first component of the target equipment, wherein the message subscription request is used for requesting to subscribe the message published to a message delivery component of the target equipment, and the target message identifies the identified message;
s22, responding to the acquired message subscription request, and determining first subscription information corresponding to the first component;
and S23, under the condition that the memory address of the target storage unit corresponding to the target message identifier is searched from the subscription table and the subscription information matched with the first subscription information does not exist in the subscription information stored in the target storage unit, adding the first subscription information into the target storage unit.
For components that have a need to subscribe to messages (i.e., message subscription components), the subscription to messages can be completed by passing a message subscription request to the messaging component. If a first component within the target device has a subscription requirement for the message identified by the target message identification, a message subscription request may be passed in to the messaging component. The message subscription request may include a target message identification and a component identification of the first component, and may be used to request a subscription to a message of the messaging component to which the subscription was published, the target message identification identifying the identified message, e.g., the target message.
Here, the messaging component may be configured with a message subscription interface for subscribing to messages, and the message subscription component may send information (equivalent to an incoming message subscription request) required for subscribing to messages to the messaging component by invoking the message subscription interface to enable subscription to messages. For instance, the first component can invoke a message subscription interface of the messaging component to import information, such as a target message identification, for subscribing to the message identified by the target message identification to enable subscription to the message identified by the target message identification.
The messaging component, upon obtaining the message subscription request sent by the first component, may determine that the first component has subscription requirements for the message identified by the target message identification. In response to the retrieved message subscription request, the messaging component may determine first subscription information corresponding to the first component. Here, the first subscription information may be used to indicate that the target message identifies a subscription relationship between the identified message and the first component. The first subscription information may be carried in the message subscription request, or may be generated based on information carried in the message subscription request.
Optionally, the messaging component may store the first subscription information, for example, store it in a memory of the application, for example, the messaging component may apply for a node and cache the first subscription information in the node of the application. The first subscription information may be temporarily stored in the message delivery component, or may be stored in other memory resources other than the message delivery component, but the address information of the corresponding memory resource may be stored in the message delivery component, so as to ensure that the message delivery component can search the stored subscription information at any time.
In order to avoid excessive waste of memory resources for storing subscription information due to repeated subscriptions and repeated distribution of messages due to storage of repeated subscription information, because the first component may have repeated subscriptions for the target message, it may be determined whether the first subscription information is a repeated subscription to the message identified by the target message identifier based on all stored subscription information corresponding to the target message identifier.
The step of determining whether the subscription is repeated may be: and searching whether a memory address of a storage unit corresponding to the target message identifier exists in a subscription table according to the target message identifier, wherein under the condition that the memory address is not searched, the situation that the message identified by the target message identifier is not subscribed and repeated subscription does not exist is shown. And when the memory address of the target storage unit corresponding to the target message identifier is found but the target storage unit does not have subscription information matched with the first subscription information, indicating that no repeated subscription exists. And under the condition that the memory address of the target storage unit corresponding to the target message identifier is found and the subscription information matched with the first subscription information exists in the target storage unit, indicating that the repeated subscription exists.
Here, it should be noted that the subscription information may include a plurality of subscription parameters, and it is determined that the subscription is a repeated subscription when all the subscription parameters are the same, otherwise, the subscription is not a repeated subscription. Further, the plurality of subscription parameters may include, but are not limited to, at least one of: message identification, component identification, RTE runtime environment, message handling functions, and the like.
In this embodiment, when the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and no subscription information matching the first subscription information exists in the subscription information stored in the target storage unit, the first subscription information may be added to the target storage unit.
According to the embodiment, the component in the device requests to subscribe the message identified by a certain message identifier through the subscription request, and the message delivery component adds the corresponding subscription information into the information storage unit when judging that the message is not the repeated subscription, so that the success rate of subscribing the message by the component can be ensured, and the resource waste caused by the repeated subscription can be avoided.
In an exemplary embodiment, after determining, in response to the obtained message subscription request, first subscription information corresponding to the first component, the method further includes:
s31, under the condition that the memory address of the information storage unit corresponding to the target message identifier is not found in the subscription table, creating the information storage unit to obtain a target storage unit;
and S32, adding the mapping relation between the target message identifier and the memory address of the target storage unit in the subscription table, and adding the first subscription information into the target storage unit.
In this embodiment, if the memory address of the information storage unit corresponding to the target message identifier is not found from the subscription table, it indicates that the message identified by the target message identifier is not subscribed by any message subscription component. In this case, a new information storage unit may be created for caching subscription information corresponding to the message subscription component that subscribes to the message identified by the target message identification. The created information storage unit is a target storage unit, and after the creation of the information storage unit is completed, the memory address of the target storage unit can be obtained.
According to the created memory address of the target storage unit, mapping calculation can be performed on the memory address and the target message identifier, and a mapping relation between the target message identifier and the memory address of the target storage unit is added in the subscription table. For the first subscription information, it may be added to the created target storage unit.
According to the embodiment, if the memory address of the information storage unit corresponding to the target message identifier does not exist in the subscription table, a new information storage unit is created, the subscription information is stored in the created information storage unit, and meanwhile, a new mapping relation is recorded in the subscription table, so that the success rate of message subscription of the component can be ensured.
In an exemplary embodiment, creating the information storage unit to obtain the target storage unit when the memory address of the information storage unit corresponding to the target message identifier is not found in the subscription table, includes:
s41, under the condition that the header address of the information linked list corresponding to the target message identifier is not found in the subscription list, creating the information linked list to obtain the target information linked list.
For the case that the information storage unit is an information linked list and the memory address of the information storage unit is a header address of the information linked list, if the header address of the information linked list corresponding to the target message identifier is not found from the subscription table, a new information linked list can be created to obtain the header address of the target information linked list, wherein the created information linked list is the target information linked list and can be used for storing the first subscription information and other subscription information corresponding to the target message identifier.
Optionally, a header address of the created target information linked list may be mapped with the target message identifier, and the mapping relationship is recorded in the subscription table, and meanwhile, the first subscription information is added to the created target information linked list. The manner of adding the first subscription information may be: the node storing the first subscription information is added to the linked list of target information, for example, by pointing to the node storing the first subscription information through a pointer.
According to the embodiment, the information linked list is created to be used for storing the subscription information, so that the storage speed of the subscription information can be improved, and the information linked list is provided for the subscription information corresponding to the same subsequent message identifier.
In an exemplary embodiment, in a case that the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and no subscription information matching the first subscription information exists in the subscription information stored in the target storage unit, adding the first subscription information to the target storage unit includes:
s51, under the condition that the header address of the target information linked list corresponding to the target message identifier is found from the subscription list and no subscription information matched with the first subscription information exists in the subscription information stored in all linked list nodes in the target information linked list, adding the target node to the tail part of the target information linked list, wherein the first subscription information is stored in the target node.
For the case that the information storage unit is an information linked list and the memory address of the information storage unit is a header address of the information linked list, the subscription information stored by all linked list nodes can be traversed in the target information linked list according to the found header address, and when the traversed subscription information is not matched with the first subscription information, the situation that repeated subscription does not exist is indicated. In this case, the target node may be added to the tail of the target information linked list to complete the recording of the first subscription information by the target information linked list, thereby completing the subscription of the first component to the message identified by the target message identifier. Here, the target node may have first subscription information stored therein.
Alternatively, a node for storing the first subscription information, i.e. the target node, may be created and the first subscription information stored in the target node. The target node may be created after receiving the first request message, or may be created after confirming that there is no subscription information matching the first subscription information. For the case that the header address of the information linked list corresponding to the target message identifier is not found from the subscription table, after the target information linked list is created, the target node storing the first subscription information may be added to the tail of the created target information linked list.
For example, when a subscriber subscribes msg _ id, whether a managed linked list head exists in a subscription table is searched according to msg _ id, and if yes, subscription information is added to the tail of the linked list. If not, a linked list head is newly built, a mapping relation is added to the subscription list, and the subscription information is added to the tail part of the linked list.
Through the embodiment, the linked list nodes in which the subscription information is cached are added at the tail part of the information linked list, so that the storage efficiency of the subscription information can be improved.
In an exemplary embodiment, after determining, in response to the obtained message subscription request, first subscription information corresponding to the first component, the method further includes:
s61, matching a preset subscription parameter in the first subscription information with a preset subscription parameter in each subscription information stored in the target storage unit when the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table, where the preset subscription parameter includes at least one of: a message identification, a component identification, a message handling function for the identified message, a runtime environment for executing the message handling function for the identified message.
If the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table, it may be determined whether subscription information matching the first subscription information exists in the subscription information stored in the target storage unit. The matching of the subscription information may be performed based on the preset subscription parameters, that is, the preset subscription parameters of the first subscription information may be matched with the preset subscription parameters in each subscription information stored in the target storage unit, so as to determine whether there is subscription information matching with the first subscription information.
In this embodiment, the preset subscription parameter may be a preset subscription parameter related to matching of the subscription information, which may be all or part of parameters in the subscription information. The preset subscription parameters may include at least one of: a message identification, a component identification, a message handling function for the identified message, a runtime environment for executing the message handling function for the identified message. Here, the meaning of the message processing function is similar to that in the foregoing embodiment, and is not described herein again. The runtime environment for executing the message processing function may be an RTE environment, and a runtime environment may or may not exist in the message subscription component.
Through the embodiment, the subscription parameters are preset for matching the subscription information, so that the situations of storage resource waste and repeated message distribution caused by repeated subscription can be avoided, and meanwhile, the efficiency and flexibility of subscription information matching can be improved.
In an exemplary embodiment, the method further comprises:
s71, acquiring a unsubscribe request of a second component of the target equipment, wherein the unsubscribe request is used for requesting to unsubscribe the message identified by the target message identification;
s72, responding to the acquired request for canceling the subscription, and determining second subscription information corresponding to the second component;
and S73, under the condition that the memory address of the target storage unit corresponding to the target message identifier is searched from the subscription table and the subscription information matched with the second subscription information exists in the subscription information stored in the target storage unit, removing the subscription information matched with the second subscription information from the target storage unit.
For components that have subscribed to the message identified by the target message identifier but no longer need to receive the message identified by the target message identifier for other reasons, unsubscribing from the message identified by the target message identifier may be accomplished by passing an unsubscribe request to the messaging component. For the second component, if it needs to unsubscribe from the message identified by the target message identification, a unsubscribe request may be transmitted to the messaging component, where the second component may be a separate component to which the target device has subscribed, and the unsubscribe request may be used to request unsubscribing from the message identified by the target message identification, and may contain the same content as the message subscription request.
Here, the messaging component may be configured with a unsubscribe interface for unsubscribing messages, and the message subscribing component may send information (equivalent to an incoming unsubscribe request) required for unsubscribing messages to the messaging component by invoking the unsubscribe interface to enable unsubscribing of messages. For example, the second component can invoke the unsubscribe interface of the messaging component to pass in information such as a target message identification for unsubscribing from a message identified by the target message identification to effectuate unsubscribing from the message identified by the target message identification.
In this embodiment, the messaging component may obtain the unsubscribe request sent by the second component. According to the acquired unsubscribe request, the message delivery component may determine second subscription information corresponding to the second component. The second subscription information may have the same parameters as the first subscription information, and the manner of determining the second subscription information is similar to the manner of determining the first subscription information, and meanwhile, the second subscription information may also be stored in a section of memory of the application in advance, which has already been described, and is not described herein again. For the second subscription information, the memory address of the information storage unit corresponding to the target message identifier in the subscription table may be searched, and if the memory address of the target storage unit corresponding to the target message identifier is found, it is determined whether the subscription information matching the second subscription information exists in the target storage unit, and the manners of searching the subscription table and determining the subscription information matching the second subscription information are similar to the manners of searching the subscription table and determining the subscription information matching the first subscription information, which are not described herein again.
If the memory address of the target storage unit corresponding to the target message identifier is not found from the subscription table, it indicates that the subscription information to be cancelled does not exist, and the cancellation process of the subscription information may be ended. If the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and the subscription information matched with the second subscription information does not exist in the subscription information stored in the target storage unit, the cancellation process of the subscription information can be ended. If the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and the subscription information matched with the second subscription information exists in the subscription information stored in the target storage unit, the subscription information matched with the second subscription information may be removed from the target storage unit, so as to complete unsubscribing of the second component to the message identified by the target message identifier.
According to the embodiment, the memory address of the corresponding information storage unit in the subscription table is searched through the message identifier, and the subscription information matched with the subscription information requested to be cancelled in the searched information storage unit is removed, so that the message is cancelled, and the accuracy of message cancellation can be improved.
In an exemplary embodiment, in a case that the memory address of the target storage unit corresponding to the target message identifier is located in the subscription table, and the subscription information stored in the target storage unit includes subscription information matching the second subscription information, removing the subscription information matching the second subscription information from the target storage unit includes:
and S81, under the condition that the header address of the target information linked list corresponding to the target message identifier is searched from the subscription list and the subscription information which is matched with the second subscription information is searched from the subscription list, the target linked list node is deleted from the target information linked list, and the memory resource occupied by the target linked list node is released.
For the case that the information storage unit is an information linked list and the memory address of the information storage unit is a header address of the information linked list, the process of removing the subscription information matched with the second subscription information from the target storage unit may be: and deleting the linked list nodes for storing the subscription information matched with the second subscription information from the target information linked list, and releasing the memory resources occupied by the linked list nodes.
In this embodiment, if the header address of the target information linked list corresponding to the target message identifier is found from the subscription table, and the subscription information in which the subscription information stored in the target linked list node in the target information linked list matches the second subscription information, the target linked list node may be deleted from the target information linked list, and the memory resource occupied by the target linked list node is released.
For example, when the msg _ id is unsubscribed, whether the mapping relation of the chain table head exists is searched in the unsubscribing table according to the msg _ id. If yes, the linked list is traversed, the subscription information to be cancelled is compared, the linked list nodes storing the matched subscription information are deleted from the linked list after matching, and the associated memory information is released.
According to the embodiment, the link list nodes storing the corresponding subscription information in the information link list are deleted, and the memory resources occupied by the link list nodes are released, so that the rationality of memory resource utilization can be improved.
In an exemplary embodiment, after removing the subscription information matching with the second subscription information from the target storage unit, the method further includes:
s91, deleting the mapping relationship between the target message identifier and the memory address of the target storage unit from the subscription table when the subscription information stored in the target storage unit is empty.
When the unsubscribe request is introduced by the second component, if the target message identifies that the identified message is subscribed only by the second component, the subscription information stored in the target storage unit is empty after the subscription information matching the second subscription information is removed from the target storage unit. For the condition that the target storage unit is the target information linked list, after the target linked list node is judged, if the depth of the target information linked list is 0, the target information linked list is represented as having no residual subscription information, otherwise, the target information linked list is determined to have residual subscription information.
In this embodiment, if the subscription information stored in the target storage unit is empty, the mapping relationship between the target message identifier and the memory address of the target storage unit may be deleted from the subscription table, so as to reduce the resource occupation amount of the subscription table by deleting the useless mapping relationship.
By the embodiment, for the condition that no other subscription information exists after the corresponding subscription information is removed from the storage unit, the corresponding mapping relation in the subscription table is deleted, so that the utilization rate of the storage resources in the subscription table can be improved.
The following explains a message passing method between components in the embodiment of the present application with an alternative example. In this optional example, the information storage unit is an information linked list, the message publishing component is a publisher, the message delivery component is a publish-subscribe component, the message subscribing component is a subscriber, and the message is denoted by msg _ id.
At present, for the situation of distributing and transmitting messages among a plurality of components in a system based on a subscription publishing manner, in order to improve the efficiency of information acquisition, a low-resource memory management scheme is provided in this optional example, so that the memory occupied by a subscription table can be reduced, and the time for searching subscription information is shortened. Optionally, the flow of the inter-component message passing method in this optional example may include the following steps:
step 1, hanging subscribers with the same msg _ id into the same linked list, performing hash mapping by taking the address of the linked list head as value and msg _ id, and recording the mapping relation in a subscription table.
And 2, when the msg _ id is issued, searching whether the mapping relation of the chain table head exists in the subscription table according to the msg _ id, if so, traversing the chain table, and distributing the message to be issued to each subscriber.
Step 3, when the subscriber subscribes msg _ id, searching whether a managed linked list head exists in a subscription list according to the msg _ id, and if so, adding subscription information to the tail of the linked list; if not, a linked list head is newly built, a mapping relation is added to the subscription list, and the subscription information is added to the tail part of the linked list.
And 4, when the msg _ id is unsubscribed, searching whether the mapping relation of the chain table head exists in the unsubscribed table according to the msg _ id, if so, traversing the chain table, comparing the information to be unsubscribed, deleting the node of the chain table from the chain table after successful matching, and releasing the associated memory information.
By the optional example, a plurality of subscriber information subscribed to the same msg _ id are managed by using the linked list, and only the mapping relation between the message identifier and the head of the linked list is stored in the subscription table, so that the memory resource occupied by the subscription table can be reduced, the time for searching the subscription information can be shortened, and the information acquisition efficiency can be improved.
It should be noted that for simplicity of description, the above-mentioned embodiments of the method are described as a series of acts, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art will recognize that the embodiments described in this specification are preferred embodiments and that acts or modules referred to are not necessarily required for this application.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, an optical disk) and includes several instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the methods of the embodiments of the present application.
According to another aspect of the embodiments of the present application, there is also provided an inter-component messaging apparatus for implementing the above inter-component messaging method. Fig. 4 is a block diagram of an alternative inter-component messaging apparatus according to an embodiment of the present application, and as shown in fig. 4, the apparatus may include:
a first obtaining unit 402, configured to obtain, by a message passing component of a target device, a target message published by a message publishing component of the target device, where the message passing component is configured to pass messages between different components of the target device, and the target message is a message identified by a target message identifier;
a searching unit 404, connected to the first obtaining unit 402, configured to search, in response to an obtained target message, a subscription table according to a target message identifier, where the subscription table is used to record a mapping relationship between a message identifier of a subscribed message and a memory address of an information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used to store subscription information corresponding to a message subscription component of the subscribed message;
a delivering unit 406, connected to the searching unit 404, configured to deliver the target message to the message subscription component corresponding to the subscription information stored in the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table.
It should be noted that the first obtaining unit 402 in this embodiment may be configured to execute the step S202, the searching unit 404 in this embodiment may be configured to execute the step S204, and the transferring unit 406 in this embodiment may be configured to execute the step S206.
Through the module, a message transmission component of the target device acquires a target message issued by a message issuing component of the target device, wherein the message transmission component is used for transmitting messages among different components of the target device, and the target message is identified by a target message identifier; responding to the acquired target message, and searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message; under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, the target message is transmitted to the message subscription component corresponding to the subscription information stored in the target storage unit, so that the problem that the efficiency of information acquisition is low due to the fact that storage resources occupied by the subscription table are large in the message transmission mode among components in the related art is solved, and the efficiency of information acquisition is improved.
In one exemplary embodiment, the transfer unit includes:
the traversal module is used for traversing each chain table node in the target information chain table according to the head address of the target information chain table under the condition that the head address of the target information chain table corresponding to the target message identifier is found in the subscription table, wherein the subscription information corresponding to one message subscription component of the message identified by the target message identifier is stored in each chain table node;
and the transmission module is used for transmitting the target message to the message subscription component corresponding to the subscription information stored in each traversed linked list node.
In an exemplary embodiment, the apparatus further includes:
a second obtaining unit, configured to obtain a message subscription request of a first component of a target device, where the message subscription request is used to request a subscription to a message published to a message delivery component of the target device, and the target message identifies an identified message;
the first determining unit is used for responding to the acquired message subscription request and determining first subscription information corresponding to the first component;
the first adding unit is used for adding the first subscription information into the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is searched from the subscription table and the subscription information matched with the first subscription information does not exist in the subscription information stored in the target storage unit.
In an exemplary embodiment, the apparatus further includes:
the creating unit is used for creating the information storage unit to obtain the target storage unit under the condition that the memory address of the information storage unit corresponding to the target message identifier is not found in the subscription table after the first subscription information corresponding to the first component is determined in response to the acquired message subscription request;
and the second adding unit is used for adding the mapping relation between the target message identifier and the memory address of the target storage unit in the subscription table and adding the first subscription information into the target storage unit.
In one exemplary embodiment, the creating unit includes:
and the creating module is used for creating the information linked list to obtain the target information linked list under the condition that the header address of the information linked list corresponding to the target message identifier is not found in the subscription list.
In one exemplary embodiment, the first adding unit includes:
and the adding module is used for adding the target node to the tail part of the target information linked list under the condition that the head address of the target information linked list corresponding to the target message identifier is searched from the subscription list and the subscription information matched with the first subscription information does not exist in the subscription information stored in all linked list nodes in the target information linked list, wherein the first subscription information is stored in the target node.
In an exemplary embodiment, the apparatus further includes:
a matching unit, configured to match a preset subscription parameter in the first subscription information with a preset subscription parameter in each subscription information stored in a target storage unit under the condition that a memory address of the target storage unit corresponding to a target message identifier is found from a subscription table after determining first subscription information corresponding to a first component in response to an acquired message subscription request, where the preset subscription parameter includes at least one of: a message identification, a component identification, a message handling function of the message identified by the message identification, a runtime environment executing the message handling function of the message identified by the message identification.
In an exemplary embodiment, the apparatus further includes:
a third obtaining unit, configured to obtain a unsubscribe request of a second component of the target device, where the unsubscribe request is used to request to unsubscribe a message identified by the target message identifier;
a second determining unit, configured to determine, in response to the obtained unsubscribe request, second subscription information corresponding to the second component;
and the removing unit is used for removing the subscription information matched with the second subscription information from the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is searched from the subscription table and the subscription information matched with the second subscription information exists in the subscription information stored in the target storage unit.
In one exemplary embodiment, the removing unit includes:
and the execution module is used for deleting the target linked list node from the target information linked list and releasing the memory resource occupied by the target linked list node under the condition that the header address of the target information linked list corresponding to the target message identifier is searched from the subscription list and the subscription information matched with the second subscription information is searched from the target information linked list and the subscription information stored by the target linked list node in the target information linked list.
In an exemplary embodiment, the apparatus further includes:
and the deleting unit is used for deleting the mapping relation between the target message identifier and the memory address of the target storage unit from the subscription table under the condition that the subscription information stored in the target storage unit is empty after the subscription information matched with the second subscription information is removed from the target storage unit.
It should be noted here that the modules described above are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above embodiments. It should be noted that the modules described above as part of the apparatus may run in a hardware environment as shown in fig. 1, may be implemented by software, and may also be implemented by hardware, where the hardware environment includes a network environment.
According to still another aspect of an embodiment of the present application, there is also provided a storage medium. Optionally, in this embodiment, the storage medium may be configured to execute a program code of a method for message passing between any one of the components in this embodiment of the present application.
Optionally, in this embodiment, the storage medium may be located on at least one of a plurality of network devices in a network shown in the above embodiment.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
s1, acquiring a target message issued by a message issuing component of target equipment through a message transmitting component of the target equipment, wherein the message transmitting component is used for transmitting messages among different components of the target equipment, and the target message is identified by a target message identifier;
s2, responding to the acquired target message, searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message;
and S3, under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, transmitting the target message to the message subscription component corresponding to the subscription information stored in the target storage unit.
Optionally, the specific example in this embodiment may refer to the example described in the above embodiment, which is not described again in this embodiment.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U disk, a ROM, a RAM, a removable hard disk, a magnetic disk, or an optical disk.
According to another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above method for message delivery between components, where the electronic device may be a server, a terminal, or a combination thereof.
Fig. 5 is a block diagram of an alternative electronic device according to an embodiment of the present application, as shown in fig. 5, including a processor 502, a communication interface 504, a memory 506, and a communication bus 508, wherein the processor 502, the communication interface 504, and the memory 506 are communicated with each other via the communication bus 508, and wherein,
a memory 506 for storing a computer program;
the processor 502, when executing the computer program stored in the memory 506, implements the following steps:
s1, acquiring a target message issued by a message issuing component of target equipment through a message transmitting component of the target equipment, wherein the message transmitting component is used for transmitting messages among different components of the target equipment, and the target message is identified by a target message identifier;
s2, responding to the acquired target message, searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message;
and S3, under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, transmitting the target message to the message subscription component corresponding to the subscription information stored in the target storage unit.
Alternatively, the communication bus may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 5, but this is not intended to represent only one bus or type of bus. The communication interface is used for communication between the electronic device and other equipment.
The memory may include RAM, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
As an example, the memory 506 may include, but is not limited to, the first obtaining unit 402, the searching unit 404, and the transferring unit 406 in the inter-component message transferring apparatus. In addition, the present invention may further include, but is not limited to, other module units in the message passing apparatus between the above components, which is not described in this example again.
The processor may be a general-purpose processor, and may include but is not limited to: a CPU (Central Processing Unit), NP (Network Processor), and the like; but also DSPs (Digital Signal Processing), ASICs (Application Specific Integrated circuits), FPGAs (Field-Programmable Gate arrays) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment is not described herein again.
It can be understood by those skilled in the art that the structure shown in fig. 5 is only an illustration, and the device implementing the method for message transmission between the components may be a terminal device, and the terminal device may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 5 is a diagram illustrating a structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 5, or have a different configuration than shown in FIG. 5.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disk, ROM, RAM, magnetic or optical disk, and the like.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including instructions for causing one or more computer devices (which may be personal computers, servers, network devices, or the like) to execute all or part of the steps of the method described in the embodiments of the present application.
In the embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be an indirect coupling or communication connection through some interfaces, units or modules, and may be electrical or in other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, and may also be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or at least two units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present application and it should be noted that, as will be apparent to those skilled in the art, numerous modifications and adaptations can be made without departing from the principles of the present application and such modifications and adaptations are intended to be considered within the scope of the present application.

Claims (13)

1. A method for inter-component messaging, comprising:
acquiring a target message issued by a message issuing component of a target device through a message transmitting component of the target device, wherein the message transmitting component is used for transmitting messages among different components of the target device, and the target message is identified by a target message identifier;
responding to the acquired target message, searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message;
and under the condition that the memory address of the target storage unit corresponding to the target message identification is found in the subscription table, transmitting the target message to a message subscription component corresponding to the subscription information stored in the target storage unit.
2. The method according to claim 1, wherein when the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table, delivering the target message to a message subscription component corresponding to the subscription information stored in the target storage unit includes:
traversing each link table node in the target information link table according to the head address of the target information link table under the condition that the head address of the target information link table corresponding to the target message identifier is found in the subscription table, wherein subscription information corresponding to one message subscription component of the message identified by the target message identifier is stored in each link table node;
and transmitting the target message to a message subscription component corresponding to the subscription information stored in each traversed linked list node.
3. The method of claim 1, further comprising:
obtaining a message subscription request of a first component of the target device, wherein the message subscription request is used for requesting a subscription to a message published to a message delivery component of the target device, and the target message identifies the identified message;
responding to the acquired message subscription request, and determining first subscription information corresponding to the first component;
and adding the first subscription information into the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and the subscription information matched with the first subscription information does not exist in the subscription information stored in the target storage unit.
4. The method according to claim 3, wherein after determining the first subscription information corresponding to the first component in response to the obtained message subscription request, the method further comprises:
under the condition that the memory address of the information storage unit corresponding to the target message identification is not found from the subscription table, establishing an information storage unit to obtain the target storage unit;
and adding the mapping relation between the target message identification and the memory address of the target storage unit in the subscription table, and adding the first subscription information into the target storage unit.
5. The method according to claim 4, wherein the creating an information storage unit to obtain the target storage unit when the memory address of the information storage unit corresponding to the target message identifier is not found in the subscription table comprises:
and under the condition that the header address of the information linked list corresponding to the target message identifier is not found in the subscription table, creating the information linked list to obtain the target information linked list.
6. The method according to claim 3, wherein the adding the first subscription information to the target storage unit when the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and no subscription information matching the first subscription information exists in the subscription information stored in the target storage unit comprises:
and adding a target node to the tail part of the target information linked list under the condition that the head address of the target information linked list corresponding to the target message identifier is searched from the subscription table and the subscription information matched with the first subscription information does not exist in the subscription information stored in all linked list nodes in the target information linked list, wherein the first subscription information is stored in the target node.
7. The method according to claim 3, wherein after determining the first subscription information corresponding to the first component in response to the obtained message subscription request, the method further comprises:
matching a preset subscription parameter in the first subscription information with the preset subscription parameter in each subscription information stored in the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table, wherein the preset subscription parameter includes at least one of the following: a message identification, a component identification, a message handling function for the identified message, a runtime environment for executing the message handling function for the identified message.
8. The method according to any one of claims 1 to 7, further comprising:
acquiring a unsubscribe request of a second component of the target equipment, wherein the unsubscribe request is used for requesting unsubscribe of the message identified by the target message identifier;
responding to the acquired request for canceling the subscription, and determining second subscription information corresponding to the second component;
and when the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and the subscription information matched with the second subscription information exists in the subscription information stored in the target storage unit, removing the subscription information matched with the second subscription information from the target storage unit.
9. The method according to claim 8, wherein in a case where the memory address of the target storage unit corresponding to the target message identifier is found from the subscription table and there is subscription information matching the second subscription information in the subscription information stored in the target storage unit, removing the subscription information matching the second subscription information from the target storage unit includes:
and under the condition that the head address of the target information linked list corresponding to the target message identifier is searched from the subscription table, and the subscription information matched with the second subscription information is searched from the subscription information stored in the target linked list node in the target information linked list, deleting the target linked list node from the target information linked list, and releasing the memory resources occupied by the target linked list node.
10. The method of claim 8, wherein after removing the subscription information that matches the second subscription information from the target storage unit, the method further comprises:
and deleting the mapping relation between the target message identifier and the memory address of the target storage unit from the subscription table under the condition that the subscription information stored in the target storage unit is empty.
11. An inter-component messaging apparatus, comprising:
a first obtaining unit, configured to obtain, by a message passing component of a target device, a target message published by a message publishing component of the target device, where the message passing component is configured to pass messages between different components of the target device, and the target message is a message identified by a target message identifier;
the searching unit is used for responding to the acquired target message and searching a subscription table according to the target message identifier, wherein the subscription table is used for recording the mapping relation between the message identifier of the subscribed message and the memory address of the information storage unit corresponding to the message identifier of the subscribed message, and the information storage unit corresponding to the message identifier of the subscribed message is used for storing the subscription information corresponding to the message subscription component of the subscribed message;
and the delivery unit is used for delivering the target message to the message subscription component corresponding to the subscription information stored in the target storage unit under the condition that the memory address of the target storage unit corresponding to the target message identifier is found in the subscription table.
12. A computer-readable storage medium, comprising a stored program, wherein the program when executed performs the method of any of claims 1 to 10.
13. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 10 by means of the computer program.
CN202211349243.7A 2022-10-31 2022-10-31 Method and device for transmitting messages among components, storage medium and electronic device Pending CN115766314A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202211349243.7A CN115766314A (en) 2022-10-31 2022-10-31 Method and device for transmitting messages among components, storage medium and electronic device
PCT/CN2022/135688 WO2024092939A1 (en) 2022-10-31 2022-11-30 Inter-component message transmission method and apparatus, storage medium, and electronic apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211349243.7A CN115766314A (en) 2022-10-31 2022-10-31 Method and device for transmitting messages among components, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN115766314A true CN115766314A (en) 2023-03-07

Family

ID=85355991

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211349243.7A Pending CN115766314A (en) 2022-10-31 2022-10-31 Method and device for transmitting messages among components, storage medium and electronic device

Country Status (2)

Country Link
CN (1) CN115766314A (en)
WO (1) WO2024092939A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117194080A (en) * 2023-11-08 2023-12-08 恒生电子股份有限公司 Message processing method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1713219A1 (en) * 2005-04-15 2006-10-18 France Telecom Communications device and method
US10645181B2 (en) * 2016-12-12 2020-05-05 Sap Se Meta broker for publish-subscribe-based messaging
CN107888499A (en) * 2017-11-17 2018-04-06 北京邮电大学 A kind of distribution subscription system and message forwarding method based on SDN
CN109491617B (en) * 2018-11-16 2022-10-04 广州创想云科技有限公司 Data storage and forwarding method, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117194080A (en) * 2023-11-08 2023-12-08 恒生电子股份有限公司 Message processing method and device
CN117194080B (en) * 2023-11-08 2024-02-06 恒生电子股份有限公司 Message processing method and device

Also Published As

Publication number Publication date
WO2024092939A1 (en) 2024-05-10

Similar Documents

Publication Publication Date Title
CN108737534B (en) Block chain-based data transmission method and device and block chain system
CN110049503B (en) Method and equipment for acquiring data
CN110633442A (en) Pushing method and device and electronic equipment
CN109618176B (en) Processing method, equipment and storage medium for live broadcast service
CN113141383B (en) Device information subscription method, client, server, system and storage medium
CN107026879B (en) Data caching method and background application system
CN115766314A (en) Method and device for transmitting messages among components, storage medium and electronic device
CN110297718B (en) Interface element linkage processing method, device and equipment
CN108366098B (en) Data interaction method and device for network nodes
CN108924043A (en) System monitoring method, gateway communication, gateway apparatus, service processing equipment
CN114090623A (en) Method and device for creating cache resources, electronic equipment and storage medium
CN114327710A (en) Function management method, management device, terminal equipment and readable storage medium
CN110798358B (en) Distributed service identification method and device, computer readable medium and electronic equipment
CN102185881A (en) Household digital equipment wireless multi-protocol space sharing storage manager and method
CN115951923A (en) Subscription event management method and related product
CN108768802B (en) Equipment information deleting method and device, server and mobile terminal
CN110933070A (en) User identification method, system, equipment and computer readable storage medium
CN113315689A (en) Information processing method, system, electronic device and readable storage medium
CN113660353B (en) Method, device, equipment and medium for managing Provisioner address based on Bluetooth Mesh
CN114090268B (en) Container management method and container management system
CN110598147A (en) Cross-domain communication method, device and equipment
WO2024092941A1 (en) Component information processing method and apparatus, and storage medium and electronic apparatus
CN109005448B (en) Bullet screen message distribution method, device, equipment and storage medium
CN110572271B (en) Method and system for managing voice chat room
CN114006939A (en) Message pushing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination