A method, system, device and storage medium for publish / subscribe under a multi-processor
By introducing a proxy service into a multiprocessor system, the single point of failure problem of a single processor is solved, flexible interaction between subscribers and publishers among multiple processors is realized, the scalability and reliability of the system are improved, and timely delivery and stable transmission of messages are ensured.
Patent Information
- Application Number
- CN202411725647.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-11-28
AI Technical Summary
The publish-subscribe model of a single processor in the existing technology has the risk of single point of failure, which makes the system unreliable, unsuitable for multiprocessor systems, and cannot guarantee the timely delivery and reliability of messages.
A proxy service is introduced as an intermediary layer to forward subscription requests and unsubscribe messages among multiple processors. The proxy service establishes a list of subscribers, manages the interaction between subscribers and publishers, and ensures accurate message delivery and exception handling.
It improves the scalability and reliability of multiprocessor systems, reduces system complexity, enhances flexibility and stability between subscribers and publishers, and reduces data loss and transmission delays caused by network or equipment failures.
Smart Images

Figure CN119583639B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of publish-subscribe technology, and more specifically, to a publish-subscribe method, system, device, and storage medium under a multiprocessor architecture. Background Technology
[0002] The publish-subscribe pattern is a software architecture design pattern, belonging to the behavioral design pattern, used to decouple the relationship between producers and consumers. In this pattern, publishers are responsible for publishing messages; they typically don't know who will receive the messages, but simply send them to the message queues they are connected to. Subscribers, on the other hand, can choose to subscribe to the message types they are interested in. Publishers publish messages, and the operation type can be add or delete; after receiving the messages, subscribers perform the corresponding operation.
[0003] The publish-subscribe method in the prior art is implemented through standard inter-process communication, so publishers and subscribers can only run on a single processor. The message broker maintains one or more data structures internally. Subscribers register themselves by sending a subscription request to the message broker, indicating that they are interested in a certain topic or a series of topics, so that the corresponding publisher will send messages to the subscribed subscribers.
[0004] However, the publish-subscribe pattern implemented on a single processor is at risk of a single point of failure. If the processor or message broker fails, the entire system will not function properly, resulting in message loss or processing delays. Furthermore, when there are multiple processors in an embedded system, each of which performs different tasks independently, the publisher and subscriber may be located on different processors, and existing publish-subscribe methods cannot be used in multi-processor scenarios. Summary of the Invention
[0005] To address at least one deficiency or improvement need in the prior art, the present invention provides a publish-subscribe method, system, device, and storage medium under multiprocessor architecture, which solves the problem that the risk of single point of failure exists in a single processor in the prior art. If the processor or message broker fails, the entire system will not function properly, resulting in message loss or processing delay, and it is not applicable to multiprocessor systems.
[0006] To achieve the above objectives, according to a first aspect of the present invention, a publish-subscribe method under a multiprocessor architecture is provided, comprising subscribers and publishers under a multiprocessor architecture, including:
[0007] The generated subscription request message is forwarded to the publisher through the proxy service in the processor to build a list of subscribers, and a subscription response message is generated and sent back to the corresponding subscribers.
[0008] If the data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor.
[0009] If a subscriber needs to unsubscribe, the unsubscribe message is sent to the corresponding publisher through the agent service in the processor, and the corresponding subscriber is removed from the subscriber list based on the unsubscribe message.
[0010] In one possible implementation, the generated subscription request message is forwarded to the publisher to establish a subscriber list via a proxy service in the processor, and a subscription response message is generated and sent back to the corresponding subscriber. This also includes:
[0011] The subscription request message includes the subscription data type, subscriber ID, and publisher ID;
[0012] The processor ID of the publisher is determined based on the publisher ID, and the subscription request message is forwarded to the publisher corresponding to the processor through the proxy service;
[0013] After receiving the subscription request message, the publisher adds the subscriber ID to the subscriber list corresponding to the subscription data type.
[0014] In one possible implementation, the generated subscription request message is forwarded to the publisher to establish a subscriber list via a proxy service in the processor, and a subscription response message is generated and sent back to the corresponding subscriber. This also includes:
[0015] When the publisher generates a subscription request message, it simultaneously starts a resubscription timer;
[0016] If the publisher does not receive a subscription response message within the subscription timeout period, it will resend the subscription request message.
[0017] In one possible implementation, if the data message changes or a new subscriber appears, the data message to be sent is sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor. This also includes:
[0018] Retrieve the subscriber IDs to be sent from the subscriber list;
[0019] Based on the subscriber ID to be sent, the data message to be sent is sent to the corresponding subscriber through the proxy service;
[0020] After the publisher sends the data to be sent, it uploads the data message to the retransmission queue and starts the retransmission timer.
[0021] If a subscriber does not receive the data message to be sent within the retransmission timeout period, it will retransmit the data message to be sent in the retransmission queue.
[0022] In one possible implementation, if the data message changes or a new subscriber appears, the data message to be sent is sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor. This also includes:
[0023] When the proxy service receives the data message to be sent, it stores the data message to be sent into the cache queue;
[0024] If the buffer queue is full, received data messages to be sent will be lost.
[0025] In one possible implementation, when a subscriber needs to unsubscribe, a subscription cancellation message is sent to the corresponding publisher via a proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the subscription cancellation message. This also includes:
[0026] The subscription cancellation message includes the subscription data type, subscriber ID, and publisher ID;
[0027] Determine the processor ID to which the publisher belongs based on the publisher ID, and forward the subscription unsubscribe message to the publisher corresponding to the processor through the proxy service;
[0028] After receiving the subscription cancellation message, the publisher will remove the subscriber ID from the subscriber list corresponding to the subscription data type.
[0029] In one possible implementation, when a subscriber needs to unsubscribe, a subscription cancellation message is sent to the corresponding publisher via a proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the subscription cancellation message. This also includes:
[0030] When the publisher generates a subscription cancellation message, a subscription cancellation timer is started simultaneously;
[0031] If the publisher does not receive a cancellation response within the subscription cancellation period, it will resend the subscription cancellation message.
[0032] According to a second aspect of the present invention, a publish-subscribe system under a multiprocessor architecture is also provided, comprising:
[0033] The subscription initiation module is configured to forward the generated subscription request message to the publisher through the proxy service in the processor to build a list of subscribers and generate subscription response messages to the corresponding subscribers.
[0034] The data publishing module is configured to send the data message to be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor if the data message changes or a new subscriber appears.
[0035] The subscription cancellation module is configured to send a subscription cancellation message to the corresponding publisher through the proxy service in the processor if a subscriber needs to cancel their subscription, and remove the corresponding subscriber from the subscriber list based on the subscription cancellation message.
[0036] According to a third aspect of the present invention, a multiprocessor publish-subscribe device is also provided, comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the steps of any of the above-described multiprocessor publish-subscribe methods.
[0037] According to a fourth aspect of the invention, a storage medium is also provided that stores a computer program executable by an access authentication device, which, when run on the access authentication device, causes the access authentication device to perform the steps of the publish-subscribe method under any of the preceding multiprocessors.
[0038] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects:
[0039] This invention provides a publish-subscribe method for multiprocessors. By using a proxy service to forward subscription requests and unsubscribe messages among multiple processors, the interaction between subscribers and publishers across the multiprocessors becomes more flexible. This allows the system to easily add or remove subscribers and publishers, thereby improving system scalability. The introduction of the proxy service simplifies direct communication between subscribers and publishers across multiple processors. Subscribers and publishers do not need to know each other's specific locations and states; they only need to interact with the proxy service, thus reducing system complexity and making system maintenance and debugging easier. Using the proxy service as an intermediary layer allows for monitoring and management of the processing of subscription requests and unsubscribe messages. If anomalies or errors occur, the proxy service can take appropriate measures for recovery or alerts, thereby enhancing system reliability and stability. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 A flowchart illustrating an embodiment of the publish-subscribe method under a multiprocessor architecture provided by the present invention;
[0042] Figure 2This is a timing diagram illustrating an embodiment of the subscription initiation process provided by the present invention;
[0043] Figure 3 A timing diagram illustrating an embodiment of the data release process provided by the present invention;
[0044] Figure 4 A timing diagram illustrating an embodiment of the subscription cancellation process provided by the present invention;
[0045] Figure 5 A schematic diagram of the structure of an embodiment of the publish-subscribe system under a multiprocessor architecture provided by the present invention;
[0046] Figure 6 This is a schematic diagram of the structure of a publish-subscribe device under a multiprocessor architecture provided in an embodiment of the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0048] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0049] This invention provides a publish / subscribe method, system, device, and storage medium under a multiprocessor architecture, which will be described below.
[0050] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the publish-subscribe method under a multiprocessor architecture provided by the present invention. In a specific embodiment of the present invention, a publish-subscribe method under a multiprocessor architecture is disclosed, including subscribers and publishers under a multiprocessor architecture, comprising:
[0051] S101. The generated subscription request message is forwarded to the publisher through the proxy service in the processor to establish a subscriber list, and a subscription response message is generated and fed back to the corresponding subscriber;
[0052] S102. If the data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor.
[0053] S103. If a subscriber needs to unsubscribe, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the subscription cancellation message.
[0054] In the above embodiments, subscribers send subscription request messages through proxy services in their respective processors. The proxy service acts as an intermediary, responsible for relaying information between processors and passing it to proxy services in other processors, ensuring that the subscription request is delivered to the publisher accurately. Upon receiving a subscription request, the publisher creates a subscriber list based on the request content. This list records detailed information about all subscribers interested in the specific data message. After completing this step, the publisher sends a subscription response message to each subscriber through the proxy service as a formal response to their subscription request.
[0055] As time goes by, when the content of the data message changes, or when new subscribers appear in the system, the proxy service will detect the changes in data information and subscribers in real time. The corresponding publisher will send the updated data message to all subscribers in the subscriber list or send the historical data information to the new subscribers, thereby ensuring the timely delivery of data and ensuring that subscribers can receive all the updates they are interested in.
[0056] On the other hand, if a subscriber decides to stop receiving updates for a particular data message, the subscriber can send a subscription cancellation message to the corresponding publisher through the agent service in the processor. Upon receiving this message, the publisher will immediately update its subscriber list, removing the subscriber's information from the list, thereby ceasing to send unnecessary data messages to it.
[0057] It is worth noting that this approach not only improves the efficiency of data message delivery but also enhances the system's flexibility and scalability. By introducing a proxy service as an intermediary, the system can easily cope with dynamic changes in subscribers and publishers without requiring large-scale modifications or adjustments to the system architecture. Furthermore, the presence of the proxy service makes communication between subscribers and publishers more reliable and stable, reducing the risk of data loss or transmission delays due to network or equipment failures.
[0058] Compared to existing technologies, this embodiment provides a publish-subscribe method for multi-processors. By using a proxy service to forward subscription requests and unsubscribe messages among multiple processors, the interaction between subscribers and publishers across multiple processors becomes more flexible. This allows the system to easily add or remove subscribers and publishers, thereby improving system scalability. The introduction of the proxy service simplifies direct communication between subscribers and publishers across multiple processors. Subscribers and publishers do not need to know each other's specific locations and states; they only need to interact with the proxy service, thus reducing system complexity and making system maintenance and debugging easier. Using the proxy service as an intermediary layer allows for monitoring and management of the processing of subscription requests and unsubscribe messages. If anomalies or errors occur, the proxy service can take appropriate measures for recovery or alerts, thereby enhancing system reliability and stability.
[0059] In some embodiments of the present invention, the generated subscription request message is forwarded to the publisher to establish a subscriber list through a proxy service in the processor, and a subscription response message is generated and fed back to the corresponding subscriber. The method further includes:
[0060] The subscription request message includes the subscription data type, subscriber ID, and publisher ID;
[0061] The processor ID of the publisher is determined based on the publisher ID, and the subscription request message is forwarded to the publisher corresponding to the processor through the proxy service;
[0062] After receiving the subscription request message, the publisher adds the subscriber ID to the subscriber list corresponding to the subscription data type.
[0063] In the above embodiments, the subscription request message must contain sufficient information to ensure that the message can be processed and routed correctly. Specifically, the subscription request message should include the subscription data type (which determines the category of information the subscriber is interested in), the subscriber ID (used to uniquely identify the entity initiating the subscription request), and the publisher ID (indicating the target source of the subscription request).
[0064] The publisher's processor ID is determined by analyzing the publisher ID in the subscription request message. This processor location can be quickly pinpointed using a pre-established mapping or query service. Once the processor ID is determined, the subscription request message can be forwarded to the corresponding publisher via a proxy service. The proxy service acts as a bridge, responsible for message delivery and routing, ensuring that the subscription request reaches the target publisher accurately.
[0065] Upon receiving a subscription request message, the publisher adds a subscriber ID to its maintained subscriber list based on the data type specified in the message. This ensures that when the publisher releases new data, it can accurately push the data to all relevant subscribers. Furthermore, the publisher can manage the subscriber list as needed, such as removing unnecessary subscriber IDs, to maintain the list's accuracy and validity.
[0066] Furthermore, to enhance system reliability and user experience, after successfully processing a subscription request, the publisher generates a subscription response message through a proxy service and sends it back to the corresponding subscriber. The subscription response message typically includes the processing result of the subscription request, the subscriber ID, and any additional information (such as the subscription validity period and data update frequency). Therefore, subscribers can promptly understand whether their subscription request has been accepted and the relevant subscription details.
[0067] In some embodiments of the present invention, the generated subscription request message is forwarded to the publisher to establish a subscriber list through a proxy service in the processor, and a subscription response message is generated and fed back to the corresponding subscriber. The method further includes:
[0068] When the publisher generates a subscription request message, it simultaneously starts a resubscription timer;
[0069] If the publisher does not receive a subscription response message within the subscription timeout period, it will resend the subscription request message.
[0070] In the above embodiments, when the publisher generates a subscription request message, the system simultaneously starts a resubscription timer. The purpose of the resubscription timer is to provide a fault tolerance mechanism during the subscription process to cope with possible network latency, message loss, or processing delays. The resubscription timer is set to a specific time interval, which is usually determined based on the expected performance of the system and the timeliness requirements of the subscription; this invention does not impose further limitations on this.
[0071] Determining the processor ID of the publisher based on the publisher ID in the subscription request message requires a pre-established mapping relationship or query service, which can quickly locate the processor where the publisher is located. Once the processor ID is determined, the system forwards the subscription request message to the publisher corresponding to that processor through a proxy service. The proxy service is responsible for message delivery and routing, ensuring that the subscription request reaches the target publisher accurately.
[0072] Upon receiving a subscription request message, the publisher adds a subscriber ID to its maintained subscriber list based on the data type specified in the message. This establishes a subscription relationship, ensuring that new data is accurately pushed to all relevant subscribers when the publisher releases new data. Simultaneously, the publisher manages the subscriber list as needed, such as removing unnecessary subscriber IDs, to maintain its accuracy and validity.
[0073] Due to the complexity and uncertainty of the network environment, publishers may sometimes fail to receive subscription response messages within the expected time. To address this, the system sets a subscription timeout on the publisher's side. If the publisher does not receive a subscription response message within the timeout period, the system will trigger a mechanism to resend the subscription request message. This mechanism relies on a previously started resubscription timer. When the timer reaches the set interval, the system will generate a new subscription request message and resend it to the target publisher through the proxy service.
[0074] The process of resending a subscription request message is similar to the initial sending, including message construction, routing, and processing. However, to avoid infinite resending loops, the system typically sets a maximum number of retries. If a subscription response message is not received after reaching the maximum number of retries, the system will log an error, notify the administrator, or take other appropriate error handling measures.
[0075] To enhance system reliability and user experience, after successfully processing a subscription request (whether it's the initial request or a resentment), the publisher generates a subscription response message through a proxy service and sends it back to the corresponding subscriber. The subscription response message typically includes the processing result of the subscription request, the subscriber ID, and any additional information (such as the subscription validity period, data update frequency, etc.). Subscribers can promptly understand whether their subscription request has been accepted and related subscription details.
[0076] In some embodiments of the present invention, if the data message changes or a new subscriber appears, the data message to be sent is sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor, and the method further includes:
[0077] Retrieve the subscriber IDs to be sent from the subscriber list;
[0078] Based on the subscriber ID to be sent, the data message to be sent is sent to the corresponding subscriber through the proxy service;
[0079] After the publisher sends the data to be sent, it uploads the data message to the retransmission queue and starts the retransmission timer.
[0080] If a subscriber does not receive the data message to be sent within the retransmission timeout period, it will retransmit the data message to be sent in the retransmission queue.
[0081] In the above embodiments, the system triggers a data sending process when data messages change (e.g., data updates, status changes, etc.) or when a new subscriber appears in the system. This triggering condition ensures that subscribers can obtain the data information they are interested in in a timely manner, whether it is a data update or the addition of a new subscriber.
[0082] Next, the system retrieves the subscriber IDs associated with the data message to be sent from the subscriber list. These subscriber IDs are matched based on the type of data message and the subscriber's subscription preferences to ensure that only subscribers interested in specific data will receive the corresponding message.
[0083] Then, based on the obtained subscriber ID to be sent, the system will send the data message to be sent to the corresponding subscriber through the proxy service in the processor. The proxy service is responsible for routing the data message from the publisher to the subscriber to ensure accurate data delivery.
[0084] To enhance system reliability, the publisher implements a series of retransmission mechanisms while sending data messages. Specifically, after sending the data to be sent, the publisher uploads the data message to a retransmission queue. This retransmission queue stores data messages that have been sent but not yet acknowledged, so that they can be retransmitted when needed.
[0085] The publisher then starts a retransmission timer. The purpose of the retransmission timer is to set a reasonable waiting time on the subscriber's end to wait for the subscriber to acknowledge receipt of the data message. If the subscriber does not send a receipt confirmation message to the publisher within the retransmission timeout period (or other preset confirmation conditions are not met), the system will consider the data message to have failed to be transmitted successfully.
[0086] To ensure the effectiveness and efficiency of the retransmission mechanism, the system can also employ several optimization strategies. For example, the timeout period of the retransmission timer can be dynamically adjusted based on network conditions; different retransmission priorities can be set for different types of data messages; and security measures such as data compression and encryption can be added during the retransmission process to improve the efficiency and security of data transmission.
[0087] In some embodiments of the present invention, if the data message changes or a new subscriber appears, the data message to be sent is sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor, and the method further includes:
[0088] When the proxy service receives the data message to be sent, it stores the data message to be sent into the cache queue;
[0089] If the buffer queue is full, received data messages to be sent will be lost.
[0090] In the above embodiments, to ensure smooth data transmission and system stability, when the proxy service receives a data message to be sent, it stores the message in a cache queue. This cache queue acts as a data buffer, temporarily storing data messages to be sent during peak data transmission periods or network congestion to avoid data loss and system overload.
[0091] However, the capacity of the cache queue is limited. If the number of data messages received by the proxy service exceeds the capacity limit of the cache queue (i.e., the cache queue is full), the system may face the risk of data loss. In this case, to maintain system stability and avoid more serious consequences (such as system crashes, data inconsistencies, etc.), the proxy service may choose to lose (i.e. discard) the received data messages to be sent.
[0092] To avoid or reduce data loss, the system can take several preventative measures. For example, it can periodically monitor the usage of the cache queue and dynamically adjust the queue capacity as needed; it can optimize data transmission strategies to reduce data transmission peaks and frequencies; and it can introduce data backup and recovery mechanisms to enable rapid data recovery in the event of loss.
[0093] In addition, after the proxy service stores the data message to be sent into the cache queue, it will retrieve the data message from the cache queue according to certain strategies (such as first-in-first-out, priority scheduling, etc.) based on the subscriber ID and data priority, and send it to the corresponding subscriber through the proxy service in the processor. The sending process may involve data serialization, encryption, compression and other processing to ensure data integrity and security.
[0094] During data transmission, the system can also employ acknowledgment and retransmission mechanisms to enhance data reliability. For example, the publisher can wait for a receipt confirmation message from the subscriber after sending the data message; if the subscriber does not send a receipt confirmation message within a certain period of time, the publisher can retransmit the data message. These mechanisms help reduce data loss and ensure accurate data transmission.
[0095] In some embodiments of the present invention, when a subscriber needs to unsubscribe, a subscription cancellation message is sent to the corresponding publisher through a proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the subscription cancellation message. The method further includes:
[0096] The subscription cancellation message includes the subscription data type, subscriber ID, and publisher ID;
[0097] Determine the processor ID to which the publisher belongs based on the publisher ID, and forward the subscription unsubscribe message to the publisher corresponding to the processor through the proxy service;
[0098] After receiving the subscription cancellation message, the publisher will remove the subscriber ID from the subscriber list corresponding to the subscription data type.
[0099] In the above embodiments, when a subscriber decides to unsubscribe, they construct a subscription cancellation message. This message must contain sufficient information to ensure the publisher can accurately identify and process the cancellation request. Specifically, the subscription cancellation message should include the following: the subscription data type (indicating the data category the subscriber is no longer interested in), the subscriber ID (used to uniquely identify the subscriber entity that initiated the cancellation request), and the publisher ID (indicating the target source of the cancellation request). This information collectively constitutes the core content of the subscription cancellation message, providing the foundation for subsequent processing.
[0100] The system determines the processor ID of the publisher based on the publisher ID in the subscription / cancellation message. This also relies on a pre-established mapping or query service that can quickly locate the publisher's processor position. Once the processor ID is determined, the system forwards the subscription / cancellation message to the corresponding publisher through a proxy service in the processor network. The proxy service acts as a bridge, responsible for message delivery and routing, ensuring the subscription / cancellation message reaches the target publisher accurately.
[0101] After receiving a subscription cancellation message, the publisher will locate the corresponding subscriber list based on the subscription data type and subscriber ID in the message. The subscriber list is a data structure maintained by the publisher that records all subscriber IDs interested in that data type. The publisher will then search for and delete the corresponding subscriber ID from the subscriber list, thereby terminating the subscription relationship. This ensures that when the publisher has new data to publish, it will no longer push data to subscribers who have already canceled their subscriptions.
[0102] After deleting a subscriber ID, the publisher can perform some follow-up actions. For example, the publisher can update the subscriber list statistics (such as the number of subscribers, data type distribution, etc.) to better manage and optimize the subscription relationship. Furthermore, the publisher can send feedback to the subscriber (if the subscriber requests feedback) to confirm the successful execution of the unsubscribe operation.
[0103] To ensure the reliability and accuracy of the unsubscription process, the system can take additional measures. For example, subscribers can be required to authenticate before sending the unsubscription cancellation message to prevent malicious unsubscription or accidental actions; transaction processing mechanisms can be added when the publisher processes unsubscription requests to ensure data consistency and integrity; and subscriber history can be retained for a period of time after unsubscription for auditing or data analysis.
[0104] In some embodiments of the present invention, when a subscriber needs to unsubscribe, a subscription cancellation message is sent to the corresponding publisher through a proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the subscription cancellation message. The method further includes:
[0105] When the publisher generates a subscription cancellation message, a subscription cancellation timer is started simultaneously;
[0106] If the publisher does not receive a cancellation response within the subscription cancellation period, it will resend the subscription cancellation message.
[0107] In the above embodiment, when generating the subscription cancellation message, the publisher simultaneously starts a subscription cancellation timer. This timer provides the publisher with a reasonable waiting window to await the subscriber's (or the system's) confirmation of the cancellation request. If the publisher does not receive a cancellation response from the subscriber (or the system) within the time set by the subscription cancellation timer, the publisher assumes that the previous cancellation request may have failed to be delivered or processed, thus triggering a retransmission mechanism.
[0108] The publisher will regenerate (or resend) the previously generated subscription cancellation message and resend it to the subscriber (or system) through the broker service in the processor. This resend may use a different routing strategy or transport protocol to increase the likelihood of successful message delivery. Simultaneously, the publisher will restart the subscription cancellation timer and continue waiting for the cancellation acknowledgment message.
[0109] On the publisher side, once a cancellation response message is received from the subscriber (or the system), the publisher will immediately stop the subscription cancellation timer and delete the corresponding subscriber ID from the subscriber list. This marks the formal termination of the subscription relationship, and the publisher will no longer send data messages of the relevant data type to that subscriber.
[0110] To ensure the reliability and accuracy of the unsubscription process, the system can take additional measures. For example, subscribers can be required to authenticate before sending the unsubscription cancellation message to prevent malicious unsubscription or accidental actions; transaction processing mechanisms can be added when the publisher processes unsubscription requests to ensure data consistency and integrity; and subscriber history can be retained for a period of time after unsubscription for auditing or data analysis.
[0111] Furthermore, the system can optimize time parameter settings in the subscription cancellation process. For example, the timeout period of the subscription cancellation timer can be dynamically adjusted based on factors such as network conditions, system load, and dynamic changes in subscription relationships; different retransmission strategies and priorities can be set for different types of cancellation requests based on information such as the importance of the subscription data type and the subscriber's priority.
[0112] In one specific embodiment of the present invention, the publish-subscribe process between two processors is described in detail. The publish-subscribe process between other processors can be deduced similarly.
[0113] Please see Figure 2 , Figure 2 A timing diagram illustrating an embodiment of the subscription initiation process provided by the present invention is shown below:
[0114] The publisher starts the publisher service and waits for subscribers to subscribe.
[0115] Furthermore, the subscriber sends a subscription message to broker service 1 and starts a resubscription timer. If the subscriber does not receive a response message from the publisher before the timer expires, it resends the subscription message.
[0116] Furthermore, after receiving the subscription message, agent service 1 forwards the subscription message to agent service 2 through the inter-processor communication interface based on the processor ID of the publisher in the subscription message.
[0117] Furthermore, after receiving the subscription message forwarded by agent service 1, agent service 2 forwards the subscription message to the publisher based on the publisher ID;
[0118] Furthermore, after receiving the subscription message, the publisher adds the subscriber to the subscriber queue for that data type, based on the data type. Then, it sends a subscription response message to the publisher.
[0119] Furthermore, after receiving the subscription response message, agent service 2 forwards the subscription response message to agent service 1 through the inter-processor communication interface based on the processor ID of the subscriber in the subscription response message.
[0120] Furthermore, after receiving the subscription response message, agent service 1 forwards the subscription response message to the subscriber based on the subscriber ID;
[0121] Furthermore, after receiving the response message, the subscriber cancels the resubscription timer. Then, it begins receiving data messages;
[0122] Furthermore, the subscriber has successfully subscribed to the message.
[0123] Please see Figure 3 , Figure 3 A timing diagram illustrating an embodiment of the data publishing process provided by the present invention is shown below:
[0124] When a publisher changes a piece of data it has published—whether by adding, modifying, or deleting it—the publisher will iterate through the subscriber queue for that data type and send the data message to each subscriber. Alternatively, if a new subscriber successfully subscribes, the publisher will send the data message to that subscriber.
[0125] Furthermore, after receiving the data message, agent service 2 forwards the data message to agent service 1 through the inter-processor communication interface, based on the subscriber's processor ID in the data message. Agent service 2 adds each sent data message to the data retransmission queue. If no data acknowledgment message is received from the subscriber before the retransmission timer expires, the data message will be retransmitted. If the number of retransmission data nodes in the retransmission queue equals the sliding window N, then agent service 2 stops receiving data messages from the publisher until the number of retransmission data nodes drops to N / 2.
[0126] Furthermore, after receiving a data message, proxy service 1 adds the data message to a cache queue with a size of N. Then, proxy service 1 forwards the data messages to subscribers according to their sequence numbers. If the cache queue is full, the received data messages are discarded.
[0127] Furthermore, after receiving the data message, the subscriber saves the data content and processes it accordingly. Finally, the subscriber sends a data response message to the publisher.
[0128] Furthermore, after receiving the data response message, agent service 1 forwards the data response message to agent service 2 through the inter-processor communication interface, based on the processor ID of the publisher in the data response message.
[0129] Furthermore, after receiving the data response message forwarded by agent service 1, agent service 2 forwards the data response message to the publisher based on the publisher ID;
[0130] Furthermore, upon receiving the data response message, the publisher removes the data message from the data retransmission queue.
[0131] Furthermore, the publisher completes the data release.
[0132] Please see Figure 4 , Figure 4 A timing diagram illustrating an embodiment of the subscription cancellation process provided by the present invention is shown below:
[0133] Subscribers need to unsubscribe by sending an unsubscribe message. If the subscriber does not receive a unsubscribe response from the publisher before the resubscribe timer expires, the unsubscribe message will be resent.
[0134] After receiving the unsubscribe message, Proxy Service 1 forwards the unsubscribe message to Proxy Service 2 through the inter-processor communication interface, based on the processor ID of the publisher in the unsubscribe message.
[0135] Furthermore, after receiving the unsubscribe message forwarded by agent service 1, agent service 2 forwards the unsubscribe message to the publisher based on the publisher ID;
[0136] Furthermore, after receiving the unsubscribe message, the publisher removes the subscriber from the subscriber queue for that data type, based on the data type. Then, it sends an unsubscribe response message to the subscriber.
[0137] Furthermore, after receiving the unsubscribe response message, agent service 2 forwards the unsubscribe response message to agent service 1 through the inter-processor communication interface, based on the processor ID of the subscriber in the unsubscribe response message.
[0138] Furthermore, after receiving the unsubscribe response message, agent service 1 forwards the unsubscribe response message to the subscriber based on the subscriber ID;
[0139] Furthermore, after receiving the unsubscribe response message, the subscriber cancels the re-unsubscribe timer;
[0140] Furthermore, the subscriber was able to unsubscribe.
[0141] To better implement the publish-subscribe method under multiprocessors in the embodiments of the present invention, based on the publish-subscribe method under multiprocessors, please refer to the corresponding documentation. Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the publish-subscribe system under a multiprocessor architecture provided by the present invention. The embodiment of the present invention provides a publish-subscribe system 500 under a multiprocessor architecture, comprising:
[0142] The subscription initiation module 510 is configured to forward the generated subscription request message to the publisher through the proxy service in the processor to establish a subscriber list and generate a subscription response message to be fed back to the corresponding subscriber;
[0143] The data publishing module 520 is configured to send the data message to be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor when the data message changes or a new subscriber appears.
[0144] The subscription cancellation module 530 is configured to send a subscription cancellation message to the corresponding publisher through the proxy service in the processor if a subscriber needs to cancel their subscription, and to remove the corresponding subscriber from the subscriber list based on the subscription cancellation message.
[0145] It should be noted that the system 500 provided in the above embodiments can implement the technical solutions described in the above method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above method embodiments, and will not be repeated here.
[0146] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a publish-subscribe device under a multiprocessor architecture provided in an embodiment of the present invention. Based on the above-described publish-subscribe method under a multiprocessor architecture, the present invention also provides a publish-subscribe device under a multiprocessor architecture, which can be a computing device such as a mobile terminal, desktop computer, laptop, handheld computer, or server. The publish-subscribe device 600 under a multiprocessor architecture includes a processor 610, a memory 620, and a display 630. Figure 6 Only a portion of the components of a publish-subscribe device under a multiprocessor architecture are shown; however, it should be understood that implementation of all shown components is not required, and more or fewer components may be implemented instead.
[0147] In some embodiments, memory 620 may be an internal storage unit of the multiprocessor-based publish-subscribe device 600, such as a hard disk or memory of the multiprocessor-based publish-subscribe device 600. In other embodiments, memory 620 may be an external storage device of the multiprocessor-based publish-subscribe device 600, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the multiprocessor-based publish-subscribe device 600. Furthermore, memory 620 may include both internal storage units and external storage devices of the multiprocessor-based publish-subscribe device 600. Memory 620 is used to store application software and various types of data installed on the multiprocessor-based publish-subscribe device 600, such as program code installed on the multiprocessor-based publish-subscribe device 600. Memory 620 may also be used to temporarily store data that has been output or will be output. In one embodiment, the memory 620 stores a multiprocessor-based publish-subscribe program 640, which can be executed by the processor 610 to implement the multiprocessor-based publish-subscribe method of the various embodiments of this application.
[0148] In some embodiments, processor 610 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in memory 620 or process data, such as executing publish-subscribe methods under a multiprocessor architecture.
[0149] In some embodiments, display 630 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 630 is used to display information from the multiprocessor-based publish-subscribe device 600 and to display a visual user interface. Components 610-630 of the multiprocessor-based publish-subscribe device 600 communicate with each other via a system bus.
[0150] In one embodiment, the steps of the multiprocessor-based publish-subscribe method described above are implemented when the processor 610 executes the multiprocessor-based publish-subscribe program 640 in the memory 620.
[0151] This embodiment also provides a computer-readable storage medium storing a multiprocessor-based publish-subscribe program, which, when executed by a processor, performs the following steps:
[0152] The generated subscription request message is forwarded to the publisher through the proxy service in the processor to build a list of subscribers, and a subscription response message is generated and sent back to the corresponding subscribers.
[0153] If the data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor.
[0154] If a subscriber needs to unsubscribe, the unsubscribe message is sent to the corresponding publisher through the agent service in the processor, and the corresponding subscriber is removed from the subscriber list based on the unsubscribe message.
[0155] In summary, this invention provides a publish-subscribe method for multiprocessors. By using a proxy service to forward subscription requests and unsubscribe messages among multiple processors, the interaction between subscribers and publishers across multiple processors becomes more flexible. This allows the system to easily add or remove subscribers and publishers, thereby improving system scalability. The introduction of the proxy service simplifies direct communication between subscribers and publishers across multiple processors. Subscribers and publishers do not need to know each other's specific locations and states; they only need to interact with the proxy service, thus reducing system complexity and making system maintenance and debugging easier. Using the proxy service as an intermediary layer allows for monitoring and management of the processing of subscription requests and unsubscribe messages. If anomalies or errors occur, the proxy service can take appropriate measures for recovery or alerts, thereby enhancing system reliability and stability.
[0156] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method. The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.
[0157] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0158] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0159] In the embodiments provided in this application, it should be understood that the disclosed system can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some service interfaces; indirect couplings or communication connections between systems or units may be electrical or other forms.
[0160] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0161] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0162] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0163] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0164] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
[0165] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0166] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A publish-subscribe method under a multiprocessor architecture, comprising subscribers and publishers under a multiprocessor architecture, characterized in that, include: The generated subscription request message is forwarded to the publisher through the proxy service in the processor to build a list of subscribers, and a subscription response message is generated and sent back to the corresponding subscribers. If the data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor. If a subscriber needs to unsubscribe, the unsubscribe message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is removed from the subscriber list based on the unsubscribe message; The step of forwarding the generated subscription request message to the publisher through the proxy service in the processor to establish a subscriber list and generating a subscription response message to the corresponding subscriber also includes: The subscription request message includes the subscription data type, subscriber ID, and publisher ID; The processor ID of the publisher is determined based on the publisher ID, and the subscription request message is forwarded to the publisher corresponding to the processor through the proxy service; After receiving the subscription request message, the publisher adds the subscriber ID to the subscriber list corresponding to the subscription data type.
2. The publish-subscribe method under a multiprocessor architecture as described in claim 1, characterized in that, The provision that if a data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor, further includes: Retrieve the subscriber IDs to be sent from the subscriber list; Based on the subscriber ID to be sent, the data message to be sent is sent to the corresponding subscriber through the proxy service; After the publisher sends the data to be sent, it uploads the data message to the retransmission queue and starts the retransmission timer. If the subscriber does not receive the data message to be sent within the retransmission timeout period, it will retransmit the data message to be sent in the retransmission queue.
3. The publish-subscribe method under a multiprocessor architecture as described in claim 2, characterized in that, The provision that if a data message changes or a new subscriber appears, the data message to be sent will be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor, further includes: When the proxy service receives the data message to be sent, it stores the data message to be sent into a cache queue; If the buffer queue is full, the received data messages to be sent will be lost.
4. The publish-subscribe method under a multiprocessor architecture as described in claim 1, characterized in that, The step of sending a subscription cancellation message to the corresponding publisher through the proxy service in the processor when a subscriber needs to cancel their subscription, and removing the corresponding subscriber from the subscriber list based on the subscription cancellation message, also includes: The subscription cancellation message includes the subscription data type, subscriber ID, and publisher ID; The processor ID of the publisher is determined based on the publisher ID, and the subscription cancellation message is forwarded to the publisher corresponding to the processor through the proxy service; After receiving the subscription cancellation message, the publisher will remove the subscriber ID from the subscriber list corresponding to the subscription data type.
5. The publish-subscribe method under a multiprocessor architecture as described in claim 1, characterized in that, The step of sending a subscription cancellation message to the corresponding publisher through the proxy service in the processor when a subscriber needs to cancel their subscription, and removing the corresponding subscriber from the subscriber list based on the subscription cancellation message, also includes: When the publisher generates the subscription cancellation message, it simultaneously starts the subscription cancellation timer; If the publisher does not receive a cancellation response message within the subscription cancellation period, the subscription cancellation message will be resent.
6. A publish-subscribe system under a multiprocessor architecture, characterized in that, include: The subscription initiation module is configured to forward the generated subscription request message to the publisher through the proxy service in the processor to build a list of subscribers and generate subscription response messages to the corresponding subscribers. The data publishing module is configured to send the data message to be sent to the corresponding subscriber in the subscriber list based on the proxy service in the processor if the data message changes or a new subscriber appears. The subscription cancellation module is configured to send a subscription cancellation message to the corresponding publisher through the proxy service in the processor if a subscriber needs to cancel their subscription, and remove the corresponding subscriber from the subscriber list based on the subscription cancellation message; The step of forwarding the generated subscription request message to the publisher through the proxy service in the processor to establish a subscriber list and generating a subscription response message to the corresponding subscriber also includes: The subscription request message includes the subscription data type, subscriber ID, and publisher ID; The processor ID of the publisher is determined based on the publisher ID, and the subscription request message is forwarded to the publisher corresponding to the processor through the proxy service; After receiving the subscription request message, the publisher adds the subscriber ID to the subscriber list corresponding to the subscription data type.
7. A publish-subscribe device under a multiprocessor architecture, characterized in that, It includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the steps of the publish-subscribe method under a multiprocessor as described in any one of claims 1 to 5.
8. A storage medium, characterized in that, It stores a computer program executable by an access authentication device, which, when run on the access authentication device, causes the access authentication device to perform the steps of the publish-subscribe method under a multiprocessor as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Scalable publish / subscribe messaging systems and methods
US20090138572A1
Limiting proxy subscription propagation in a publish / subscribe message broker network
US20090182574A1