Publishing and subscribing method, system and equipment under multiple processors and storage medium

By introducing proxy services in the multiprocessor system, single point failure and multiprocessor adaptability problems in the prior art are solved, and a publish subscription model with high scalability and reliability is achieved.

CN119583639AActive Publication Date: 2025-03-07WUHAN SHIP COMM RES INST (NO 722 RES INST OF CHINA STATE SHIPBUILDING CORP)

Patent Information

Application Number
CN202411725647.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-07
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

In the prior art, the publish subscription model poses a single point of failure risk on a single processor and cannot be applied to multiprocessor systems, resulting in message loss or processing delays.

Method used

By introducing proxy services into a multiprocessor system, proxy services are responsible for forwarding subscription requests, data messages and unsubscribe messages, establishing and managing subscriber lists, ensuring reliable delivery of messages between multiple processors.

Benefits of technology

It improves the scalability and reliability of the system, reduces the complexity and maintenance difficulty of the system, and enhances the recovery ability of faults and the stability of message delivery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583639A_ABST
    Figure CN119583639A_ABST
Patent Text Reader

Abstract

The invention discloses a publishing and subscribing method, system and device under multiple processors and a storage medium, and relates to the technical field of publishing and subscribing, and the method comprises the steps: forwarding a generated subscription request message to a publisher through an agency service in a processor, building a subscriber list, generating a subscription response message, and feeding back the subscription response message to a corresponding subscriber; if the data message changes or a new subscriber appears, sending the to-be-sent data message to a corresponding subscriber in a subscriber list based on the proxy service in the processor; and if the subscriber needs to cancel subscription, sending a subscription cancel message to the corresponding publisher through the proxy service in the processor, and deleting the corresponding subscriber from the subscriber list based on the subscription cancel message. According to the invention, the proxy service is used as a middle layer among multiple processors, the subscription request and the subscription canceling message can be monitored and managed, and if an abnormity or an error occurs, the proxy service can recover or give an alarm, so that the reliability and the stability of the system are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of publish-subscribe technology, and more specifically, to a publish-subscribe method, system, device and storage medium under a multi-processor. Background Art

[0002] The publish-subscribe model is a software architecture design model, which belongs to the behavioral design model and is used to decouple the relationship between producers and consumers. In this model, publishers are responsible for publishing messages. They usually do not know who will receive the message, but just send the message to the message queue connected to them, while subscribers can choose to subscribe to the message type they are interested in. The publisher publishes the message, and the operation type can be add or delete. After receiving the message, the subscriber performs the corresponding operation.

[0003] The publish-subscribe method in the prior art is implemented through a standard inter-process communication method, so the publisher and the subscriber can only run on one processor. The message agent maintains one or more data structures internally. The subscriber registers itself by sending a subscription request to the message agent, indicating that it is interested in a certain topic or a series of topics, so that the corresponding publisher sends the message to the subscribed subscriber.

[0004] However, the publish-subscribe model implemented on a single processor has the risk of single point failure. If the processor or message broker fails, the entire system will not work properly, resulting in message loss or processing delays. When there are multiple processors in the embedded system, each processor independently performs different tasks, and the publisher and subscriber may be located on different processors, the existing publish-subscribe method cannot use multiple processors. Summary of the invention

[0005] In response to at least one defect or improvement need in the prior art, the present invention provides a publish-subscribe method, system, device and storage medium under multiple processors, which are used to solve the risk of single point failure of a single processor in the prior art. If the processor or message agent fails, the entire system will not work properly, resulting in message loss or processing delays, and the method is not applicable to multi-processor systems.

[0006] To achieve the above object, according to a first aspect of the present invention, a publish-subscribe method under a multi-processor is provided, including a subscriber and a publisher under a multi-processor, including:

[0007] The proxy service in the processor forwards the generated subscription request message to the publisher to establish a subscriber list, and generates a subscription response message to feed back to the corresponding subscriber;

[0008] If the data message changes or a new subscriber appears, the proxy service in the processor sends the data message to the corresponding subscriber in the subscriber list;

[0009] If the subscriber needs to cancel the subscription, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message.

[0010] In a possible implementation, 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, which also includes:

[0011] The subscription request message includes the subscription data type, subscriber ID and publisher ID;

[0012] Determine the processor ID of the publisher based on the publisher ID, and forward the subscription request message 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 a possible implementation, 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, which also includes:

[0015] When the publisher generates a subscription request message, the resubscription timer is started synchronously;

[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 a 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, and further includes:

[0018] Get the subscriber ID 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 information to be sent, it uploads the data message to be sent to the retransmission queue and starts the retransmission timer;

[0021] If the subscriber does not receive the data message to be sent within the retransmission timeout period, the data information to be sent in the retransmission queue will be resent.

[0022] In a 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, and further 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 cache queue is full, the received data message to be sent will be lost.

[0025] In a possible implementation, when a subscriber needs to cancel a subscription, a subscription cancellation message is sent to the corresponding publisher through a proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message, further comprising:

[0026] The subscription cancellation message includes the subscription data type, subscriber ID, and publisher ID;

[0027] Determine the processor ID of the publisher based on the publisher ID, and forward the subscription cancellation message to the publisher corresponding to the processor through the proxy service;

[0028] After receiving the subscription cancellation message, the publisher deletes the subscriber ID from the subscriber list corresponding to the subscription data type.

[0029] In a possible implementation, when a subscriber needs to cancel a subscription, a subscription cancellation message is sent to the corresponding publisher through a proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message, further comprising:

[0030] When the publisher generates a subscription cancellation message, the subscription cancellation timer is started synchronously;

[0031] If the publisher does not receive a cancellation response message within the subscription cancellation time, it will resend the subscription cancellation message.

[0032] According to a second aspect of the present invention, a publish-subscribe system under a multi-processor is also provided, comprising:

[0033] A subscription initiation module, which 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 feed back to the corresponding subscriber;

[0034] A 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 the subscriber needs to cancel the subscription, and delete the corresponding subscriber from the subscriber list based on the subscription cancellation message.

[0036] According to a third aspect of the present invention, there is also provided a publish-subscribe device under a multi-processor, which comprises at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit executes the steps of any one of the above-mentioned publish-subscribe methods under a multi-processor.

[0037] According to a fourth aspect of the present invention, there is also provided a storage medium storing a computer program executable by an access authentication device, wherein when the computer program runs on the access authentication device, the access authentication device executes the steps of any of the above-mentioned publish-subscribe methods under a multi-processor.

[0038] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:

[0039] The present invention provides a publish-subscribe method under multiple processors. Subscription requests and unsubscribe messages are forwarded between multiple processors through a proxy service, so that the interaction between subscribers and publishers between multiple processors is more flexible, and the system is allowed to easily add or delete subscribers and publishers, thereby improving the scalability of the system. The introduction of the proxy service simplifies the direct communication between subscribers and publishers between multiple processors. Subscribers and publishers between multiple processors do not need to know each other's specific location and status, and only need to interact with the proxy service, thereby reducing the complexity of the system and making the maintenance and debugging of the system easier. Using the proxy service as an intermediate layer, the processing process of subscription requests and unsubscribe messages can be monitored and managed. If an exception or error occurs, the proxy service can take corresponding measures to recover or alarm, thereby enhancing the reliability and stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 A schematic flow chart of an embodiment of a publish-subscribe method under a multi-processor provided by the present invention;

[0042] Figure 2A timing diagram of an embodiment of a subscription initiation process provided by the present invention;

[0043] Figure 3 A timing diagram of an embodiment of a data publishing process provided by the present invention;

[0044] Figure 4 A timing diagram of an embodiment of a subscription cancellation process provided by the present invention;

[0045] Figure 5 A schematic diagram of the structure of an embodiment of a publish-subscribe system under a multi-processor provided by the present invention;

[0046] Figure 6 A schematic diagram of the structure of a publish-subscribe device under a multi-processor provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present 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 and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0049] The present invention provides a publish-subscribe method, system, device and storage medium under a multi-processor, which are described below respectively.

[0050] See also Figure 1 , Figure 1 A flowchart of an embodiment of a publish-subscribe method under a multi-processor provided by the present invention is provided. In a specific embodiment of the present invention, a publish-subscribe method under a multi-processor is disclosed, including a subscriber and a publisher under the multi-processor, including:

[0051] S101, 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 feed back to the corresponding subscriber;

[0052] S102: 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;

[0053] S103: If the subscriber needs to cancel the subscription, a subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message.

[0054] In the above embodiment, the subscriber sends a subscription request message through the proxy service in the processor where the subscriber is located. The proxy service acts as an intermediary and is responsible for transmitting information between processors and passing the information to the proxy service of other processors to ensure that the subscription request can be delivered to the publisher accurately. After receiving the subscription request, the publisher will create a subscriber list based on the request content. The list records in detail the information of all subscribers who are interested in specific data messages. After completing this step, the publisher will send a subscription reply message to each subscriber through the proxy service as a formal response to its subscription request.

[0055] As time goes by, when the content of data messages changes, or new subscribers appear in the system, the proxy service will detect changes in data information and subscribers in real time. The corresponding publisher will send updated data messages to all subscribers in the subscriber list or send historical data information to new subscribers, thereby ensuring timely delivery of data and ensuring that subscribers can receive all updates of their interest.

[0056] On the other hand, if the subscriber decides not to receive updates on a data message, the subscriber can send a subscription cancellation message to the corresponding publisher through the proxy service in the processor. After receiving this message, the publisher will immediately update the subscriber list and remove the relevant information of the subscriber from the list, thereby stopping sending 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 flexibility and scalability of the system. By introducing the proxy service as an intermediary, the system can easily cope with the dynamic changes of subscribers and publishers without large-scale modification or adjustment of the system architecture. In addition, the existence of the proxy service also makes the communication between subscribers and publishers more reliable and stable, reducing the risk of data loss or transmission delay caused by network failure or equipment failure.

[0058] Compared with the prior art, the publish-subscribe method under multiple processors provided in this embodiment forwards subscription requests and unsubscribe messages between multiple processors through a proxy service, making the interaction between subscribers and publishers between multiple processors more flexible, allowing the system to easily add or delete subscribers and publishers, thereby improving the scalability of the system. The introduction of the proxy service simplifies the direct communication between subscribers and publishers between multiple processors. Subscribers and publishers between multiple processors do not need to know each other's specific location and status, and only need to interact with the proxy service, thereby reducing the complexity of the system and making the maintenance and debugging of the system easier. Using the proxy service as an intermediate layer, the processing of subscription requests and unsubscribe messages can be monitored and managed. If an exception or error occurs, the proxy service can take corresponding measures to recover or alarm, thereby enhancing the reliability and stability of the system.

[0059] In some embodiments of the present invention, 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, which also includes:

[0060] The subscription request message includes the subscription data type, subscriber ID and publisher ID;

[0061] Determine the processor ID of the publisher based on the publisher ID, and forward the subscription request message 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 embodiment, the subscription request message must contain sufficient information to ensure that the message can be correctly processed and routed. Specifically, the subscription request message should contain the subscription data type (which determines the category of information that the subscriber is interested in), the subscriber ID (used to uniquely identify the entity that initiates the subscription request), and the publisher ID (indicates the target source of the subscription request).

[0064] The publisher ID in the subscription request message is used to determine the processor ID of the publisher. The pre-established mapping relationship or query service can be used to quickly locate the processor location of the publisher. Once the processor ID is determined, the subscription request message can be forwarded to the publisher corresponding to the processor through the proxy service. The proxy service plays a bridge role here. It is responsible for the transmission and routing of messages to ensure that the subscription request can reach the target publisher accurately.

[0065] After receiving the subscription request message, the publisher will add the subscriber ID for the corresponding data type in the subscriber list it maintains according to the subscription data type in the message, ensuring that when the publisher has new data to publish, the data can be accurately pushed to all relevant subscribers. At the same time, the publisher can also manage the subscriber list as needed, such as removing subscriber IDs that are no longer needed, to maintain the accuracy and effectiveness of the list.

[0066] In addition, in order to enhance the reliability of the system and user experience, after successfully processing the subscription request, the publisher will also generate a subscription response message through the proxy service and feedback it to the corresponding subscriber. The subscription response message usually contains the processing result of the subscription request, the subscriber ID, and possible additional information (such as the validity period of the subscription, the frequency of data updates, etc.), so that the subscriber can promptly understand whether his subscription request is accepted and the relevant subscription details.

[0067] In some embodiments of the present invention, 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, which also includes:

[0068] When the publisher generates a subscription request message, the resubscription timer is started synchronously;

[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 embodiment, when the publisher generates a subscription request message, the system will synchronously start a resubscription timer. The purpose of the resubscription timer is to provide a fault-tolerant mechanism in the subscription process to cope with possible network delays, 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, and the present invention does not impose further restrictions on this.

[0071] To determine the processor ID of the publisher based on the publisher ID in the subscription request message, a pre-established mapping relationship or query service is required, which can quickly locate the processor location of the publisher. Once the processor ID is determined, the system will forward the subscription request message to the publisher corresponding to the processor through the proxy service. The proxy service is responsible for the delivery and routing of the message to ensure that the subscription request can reach the target publisher accurately.

[0072] After receiving the subscription request message, the publisher will add the subscriber ID for the corresponding data type in the subscriber list it maintains according to the subscription data type in the message, that is, establish a subscription relationship, ensuring that when the publisher has new data to publish, the data can be accurately pushed to all relevant subscribers. At the same time, the publisher will also manage the subscriber list as needed, such as removing subscriber IDs that are no longer needed, to maintain the accuracy and effectiveness of the list.

[0073] Due to the complexity and uncertainty of the network environment, sometimes the publisher may not receive the subscription response message within the expected time. In order to deal with this situation, the system sets a subscription timeout on the publisher side. If the publisher does not receive the subscription response message within the subscription timeout, the system will trigger a mechanism to resend the subscription request message. This mechanism depends on the resubscription timer started previously. When the timer reaches the set time interval, the system will generate a subscription request message again 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 process, including steps such as message construction, routing, and processing. However, in order to avoid infinite resending, the system usually sets a maximum number of retries. If the subscription response message is not received after the maximum number of retries, the system will record an error log, notify the administrator, or take other appropriate error handling measures.

[0075] In order to enhance the reliability of the system and user experience, after successfully processing a subscription request (whether it is the first time or a resent request), the publisher will generate a subscription response message through the proxy service and feedback it to the corresponding subscriber. The subscription response message usually contains the processing result of the subscription request, the subscriber ID, and possible additional information (such as the validity period of the subscription, the frequency of data updates, etc.). Subscribers can promptly understand whether their subscription requests are 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 further includes:

[0077] Get the subscriber ID 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 information to be sent, it uploads the data message to be sent to the retransmission queue and starts the retransmission timer;

[0080] If the subscriber does not receive the data message to be sent within the retransmission timeout period, the data information to be sent in the retransmission queue will be resent.

[0081] In the above embodiment, when the data message changes (e.g., data update, status change, etc.) or a new subscriber appears in the system, the system triggers the data sending process. This trigger condition ensures that subscribers can obtain the data information they are interested in in a timely manner, whether it is data update or new subscriber joining.

[0082] Next, the system obtains the subscriber IDs associated with the data message to be sent from the subscriber list. These subscriber IDs are matched according to 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] When sending data messages, in order to enhance the reliability of the system, the publisher will perform a series of retransmission mechanisms. Specifically, after sending the data information to be sent, the publisher will upload the data message to be sent to a retransmission queue. This retransmission queue is used to store data messages that have been sent but not yet confirmed to be received, so that they can be retransmitted when needed.

[0085] Subsequently, the publisher will start a retransmission timer. The purpose of the retransmission timer is to set a reasonable waiting time on the subscriber side to wait for the subscriber to confirm the received data message. If the subscriber does not send a receipt confirmation message to the publisher within the retransmission timeout period (or does not meet other preset confirmation conditions), the system will consider that the data message has not been successfully transmitted.

[0086] In order to ensure the effectiveness and efficiency of the retransmission mechanism, the system can also adopt some optimization strategies. For example, the timeout of the retransmission timer can be dynamically adjusted according to the network conditions; different retransmission priorities can be set for different types of data messages; data compression, encryption and other security measures 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 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 cache queue is full, the received data message to be sent will be lost.

[0090] In the above embodiment, in order to ensure smooth data transmission and system stability, when the proxy service receives a data message to be sent, it will store the message in a cache queue. The cache queue plays the role of data buffering, which can temporarily store the data message to be sent during the peak period of data transmission 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 to be sent received by the proxy service exceeds the capacity limit of the cache queue, that is, the cache queue is full, then the system may face the risk of data loss. In this case, in order to maintain the stability of the system and avoid more serious consequences (such as system crash, data inconsistency, etc.), the proxy service may choose to lose (i.e. discard) the received data messages to be sent.

[0092] In order to avoid or reduce data loss, the system can take some preventive measures. For example, the usage of the cache queue can be monitored regularly and the capacity of the queue can be adjusted dynamically as needed; the data sending strategy can be optimized to reduce the peak value and frequency of data sending; and a data backup and recovery mechanism can be introduced to restore data as soon as possible after data loss.

[0093] In addition, after the proxy service stores the data message to be sent into the cache queue, it will take out the data message from the cache queue according to certain strategies (such as first-in-first-out, priority scheduling, etc.) based on information such as 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 the integrity and security of the data.

[0094] During the data transmission process, the system can also use some confirmation and retransmission mechanisms to enhance the reliability of data. For example, the publisher can wait for the subscriber's receipt confirmation message after sending the data message; if the subscriber does not send the receipt confirmation message within a certain period of time, the publisher can resend 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 cancel a subscription, a subscription cancellation message is sent to a corresponding publisher through a proxy service in a processor, and the corresponding subscriber is deleted from a subscriber list based on the subscription cancellation message, further comprising:

[0096] The subscription cancellation message includes the subscription data type, subscriber ID, and publisher ID;

[0097] Determine the processor ID of the publisher based on the publisher ID, and forward the subscription cancellation message to the publisher corresponding to the processor through the proxy service;

[0098] After receiving the subscription cancellation message, the publisher deletes the subscriber ID from the subscriber list corresponding to the subscription data type.

[0099] In the above embodiment, when the subscriber decides to cancel the subscription, a subscription cancellation message is constructed, which must contain sufficient information to ensure that the publisher can accurately identify and process the cancellation request. Specifically, the subscription cancellation message should include the following: subscription data type (indicates the data category that the subscriber is no longer interested in), subscriber ID (used to uniquely identify the subscriber entity that initiated the cancellation request), and publisher ID (indicates the target source of the cancellation request). This information together constitutes the core content of the subscription cancellation message and provides a basis for subsequent processing.

[0100] The system determines the processor ID of the publisher based on the publisher ID in the subscription cancellation message. Similarly, this also relies on a pre-established mapping relationship or query service that can quickly locate the processor location of the publisher. Once the processor ID is determined, the system will forward the subscription cancellation message to the publisher corresponding to the processor through the proxy service in the processor network. The proxy service plays a bridge role here. It is responsible for the transmission and routing of messages to ensure that the subscription cancellation message can reach the target publisher accurately.

[0101] After receiving the subscription cancellation message, the publisher will locate the corresponding subscriber list according to the subscription data type and subscriber ID in the message. The subscriber list is a data structure maintained by the publisher, which records all subscriber IDs interested in the data type. The publisher will find and delete the corresponding subscriber ID in the subscriber list to cancel the subscription relationship, thereby ensuring that when the publisher has new data to publish, the data will no longer be pushed to the subscribers who have canceled their subscription.

[0102] After deleting the subscriber ID, the publisher can also perform some follow-up processing. For example, the publisher can update the statistics of the subscriber list (such as the number of subscribers, data type distribution, etc.) to better manage and optimize the subscription relationship. In addition, the publisher can also feedback the unsubscription result to the subscriber (if the subscriber requests feedback) to confirm the successful execution of the unsubscription operation.

[0103] In order to ensure the reliability and accuracy of the unsubscription process, the system can also take some additional measures. For example, the subscriber can be required to authenticate before sending the subscription cancellation message to prevent malicious unsubscription or misoperation; a transaction processing mechanism can be added when the publisher processes the unsubscription request to ensure data consistency and integrity; the subscriber's history can be retained for a period of time after the subscription is cancelled for auditing or data analysis.

[0104] In some embodiments of the present invention, when a subscriber needs to cancel a subscription, a subscription cancellation message is sent to a corresponding publisher through a proxy service in a processor, and the corresponding subscriber is deleted from a subscriber list based on the subscription cancellation message, further comprising:

[0105] When the publisher generates a subscription cancellation message, the subscription cancellation timer is started synchronously;

[0106] If the publisher does not receive a cancellation response message within the subscription cancellation time, it will resend the subscription cancellation message.

[0107] In the above embodiment, when generating a subscription cancellation message, the publisher will synchronously start a subscription cancellation timer. The purpose of this timer is to provide the publisher with a reasonable waiting time window for waiting for the subscriber (or system) to confirm the subscription cancellation request. If the publisher does not receive a cancellation response message from the subscriber (or system) within the time set by the subscription cancellation timer, the publisher will believe that the previous subscription cancellation request may not have been successfully delivered or processed, thereby triggering a retransmission mechanism.

[0108] The publisher will regenerate (or resend the previously generated) subscription cancellation message and send it to the subscriber (or system) again through the proxy service in the processor. This time, different routing strategies or transmission protocols may be used to increase the possibility of successful message delivery. At the same time, the publisher will restart the subscription cancellation timer and continue to wait for the cancellation reply message.

[0109] On the publisher side, once the publisher receives the cancellation response message sent by the subscriber (or system), the publisher will immediately stop the subscription cancellation timer and delete the corresponding subscriber ID from the subscriber list, which marks the official termination of the subscription relationship. Thereafter, the publisher will no longer send data messages of related data types to the subscriber.

[0110] In order to ensure the reliability and accuracy of the unsubscription process, the system can also take some additional measures. For example, the subscriber can be required to authenticate before sending the subscription cancellation message to prevent malicious unsubscription or misoperation; a transaction processing mechanism can be added when the publisher processes the unsubscription request to ensure data consistency and integrity; the subscriber's history can be retained for a period of time after the subscription is cancelled for auditing or data analysis.

[0111] In addition, the system can also optimize the time parameter settings in the subscription cancellation process. For example, the timeout of the subscription cancellation timer can be dynamically adjusted according to 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 subscription cancellation requests based on information such as the importance of the subscription data type and the priority of the subscriber.

[0112] In a specific embodiment of the present invention, a specific description is given by using the publish-subscribe process between two processors, and the publish-subscribe process between other multiple processors can be deduced by analogy.

[0113] See also Figure 2 , Figure 2 The timing diagram of an embodiment of the subscription initiation process provided by the present invention is as follows:

[0114] The publisher starts the publisher service and waits for the subscriber to initiate a subscription;

[0115] Further, the subscriber sends a subscription message to the proxy service 1 and starts a resubscription timer. If the subscriber does not receive a response message from the publisher before the timer times out, the subscription message is resent;

[0116] Further, after receiving the subscription message, the proxy service 1 forwards the subscription message to the proxy service 2 through the inter-processor communication interface according to the processor ID of the publisher in the subscription message;

[0117] Further, after receiving the subscription message forwarded by proxy service 1, proxy service 2 forwards the subscription message to the publisher according to the publisher ID;

[0118] Furthermore, after receiving the subscription message, the publisher adds the subscriber to the subscriber queue of the data type according to the data type. Then, it sends a subscription reply message to the publisher;

[0119] Further, after receiving the subscription response message, the proxy service 2 forwards the subscription response message to the proxy service 1 through the inter-processor communication interface according to the processor ID of the subscriber in the subscription response message;

[0120] Further, after receiving the subscription response message, the proxy service 1 forwards the subscription response message to the subscriber according to the subscriber ID;

[0121] Further, after receiving the response message, the subscriber cancels the resubscription timer and then starts receiving data messages;

[0122] Further, the subscriber successfully subscribes to the message.

[0123] See also Figure 3 , Figure 3 The following is a timing diagram of an embodiment of the data publishing process provided by the present invention, wherein the specific process is as follows:

[0124] When a data published by a publisher changes, such as addition, modification or deletion, the publisher will traverse the subscriber queue of the data type and send the data message to each subscriber; or, when a new subscriber subscribes successfully, the publisher will send the data message to the subscriber;

[0125] Furthermore, after receiving the data message, Proxy Service 2 forwards the data message to Proxy Service 1 through the inter-processor communication interface according to the processor ID of the subscriber in the data message. Proxy Service 2 adds each sent data message to the data retransmission queue. If the data response message from the subscriber is not received before the retransmission timer times out, the data message will be resent. If the number of retransmission data nodes in the retransmission queue is equal to the sliding window N, Proxy Service 2 stops receiving data messages from the publisher until the number of retransmission data nodes drops to N / 2.

[0126] Further, after receiving the data message, the proxy service 1 adds the data message to the cache queue, and the cache queue size is N. Then, the proxy service 1 forwards the data message to the subscriber in the order of the sequence number of the data message. If the cache queue is full, the received data message is discarded;

[0127] Furthermore, after receiving the data message, the subscriber saves the data content and performs corresponding processing. Finally, the subscriber sends a data response message to the publisher;

[0128] Further, after receiving the data response message, the proxy service 1 forwards the data response message to the proxy service 2 through the inter-processor communication interface according to the processor ID of the publisher in the data response message;

[0129] Further, after receiving the data response message forwarded by the proxy service 1, the proxy service 2 forwards the data response message to the publisher according to the publisher ID;

[0130] Further, the publisher receives the data response message and deletes the data message from the data retransmission queue;

[0131] Further, the publisher completes the publishing of the data.

[0132] See also Figure 4 , Figure 4 This is a timing diagram of an embodiment of the subscription cancellation process provided by the present invention, and the specific process is as follows:

[0133] The subscriber needs to cancel the subscription and send an unsubscribe message. If the subscriber does not receive the publisher's unsubscribe response message before the re-unsubscribe timer times out, 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 according to the processor ID of the publisher in the unsubscribe message;

[0135] ) Further, after receiving the unsubscribe message forwarded by the proxy service 1, the proxy service 2 forwards the unsubscribe message to the publisher according to the publisher ID;

[0136] Furthermore, after receiving the unsubscribe message, the publisher deletes the subscriber from the subscriber queue of the data type according to the data type. Then, it sends an unsubscribe reply message to the subscriber;

[0137] Further, after receiving the unsubscribe response message, proxy service 2 forwards the unsubscribe response message to proxy service 1 through the inter-processor communication interface according to the processor ID of the subscriber in the unsubscribe response message;

[0138] Further, after receiving the unsubscribe response message, the proxy service 1 forwards the unsubscribe response message to the subscriber according to the subscriber ID;

[0139] Further, after receiving the unsubscribe response message, the subscriber cancels the re-unsubscribe timer;

[0140] Furthermore, the subscriber can unsubscribe.

[0141] In order to better implement the publish-subscribe method under multiple processors in the embodiment of the present invention, based on the publish-subscribe method under multiple processors, correspondingly, please refer to Figure 5 , Figure 5 The present invention is a schematic diagram of a structure of an embodiment of a publish-subscribe system under a multi-processor provided by the present invention. The embodiment of the present invention provides a publish-subscribe system 500 under a multi-processor, including:

[0142] The subscription initiation module 510 is configured to forward the generated subscription request message to the publisher to establish a subscriber list through the proxy service in the processor, and generate a subscription response message to feed 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 if 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 the subscriber needs to cancel the subscription, and delete the corresponding subscriber from the subscriber list based on the subscription cancellation message.

[0145] It should be noted here that the system 500 provided in the above embodiment can implement the technical solutions described in the above method embodiments. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above method embodiments, which will not be repeated here.

[0146] See also Figure 6 , Figure 6 The schematic diagram of the structure of the publish-subscribe device under a multi-processor provided by an embodiment of the present invention. Based on the publish-subscribe method under a multi-processor, the present invention also provides a publish-subscribe device under a multi-processor. The publish-subscribe device under a multi-processor can be a computing device such as a mobile terminal, a desktop computer, a notebook, a palm computer, and a server. The publish-subscribe device 600 under a multi-processor includes a processor 610, a memory 620, and a display 630. Figure 6 Only some components of the publish-subscribe device under multiple processors are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.

[0147] In some embodiments, the memory 620 may be an internal storage unit of the publish-subscribe device 600 under a multiprocessor, such as a hard disk or memory of the publish-subscribe device 600 under a multiprocessor. In other embodiments, the memory 620 may also be an external storage device of the publish-subscribe device 600 under a multiprocessor, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the publish-subscribe device 600 under a multiprocessor. Further, the memory 620 may also include both an internal storage unit and an external storage device of the publish-subscribe device 600 under a multiprocessor. The memory 620 is used to store application software and various data installed in the publish-subscribe device 600 under a multiprocessor, such as the program code of the publish-subscribe device 600 under a multiprocessor. The memory 620 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the memory 620 stores a publish-subscribe program 640 under multiple processors, and the publish-subscribe program 640 under multiple processors can be executed by the processor 610, thereby implementing the publish-subscribe method under multiple processors of each embodiment of the present application.

[0148] In some embodiments, the processor 610 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes stored in the memory 620 or process data, such as executing a publish-subscribe method under a multi-processor.

[0149] In some embodiments, the display 630 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 630 is used to display information of the publish-subscribe device 600 under a multi-processor and to display a visual user interface. The components 610-630 of the publish-subscribe device 600 under a multi-processor communicate with each other through a system bus.

[0150] In one embodiment, when the processor 610 executes the publish-subscribe program 640 under multiple processors in the memory 620 , the steps in the publish-subscribe method under multiple processors are implemented.

[0151] This embodiment further provides a computer-readable storage medium on which a publish-subscribe program for multiple processors is stored. When the publish-subscribe program for multiple processors is executed by the processors, the following steps are implemented:

[0152] The proxy service in the processor forwards the generated subscription request message to the publisher to establish a subscriber list, and generates a subscription response message to feed back to the corresponding subscriber;

[0153] If the data message changes or a new subscriber appears, the proxy service in the processor sends the data message to the corresponding subscriber in the subscriber list;

[0154] If the subscriber needs to cancel the subscription, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message.

[0155] In summary, the present invention provides a publish-subscribe method under multiple processors, which forwards subscription requests and unsubscribe messages between multiple processors through a proxy service, making the interaction between subscribers and publishers between multiple processors more flexible, allowing the system to easily add or delete subscribers and publishers, thereby improving the scalability of the system. The introduction of the proxy service simplifies the direct communication between subscribers and publishers between multiple processors. Subscribers and publishers between multiple processors do not need to know each other's specific location and status, and only need to interact with the proxy service, thereby reducing the complexity of the system and making the maintenance and debugging of the system easier. Using the proxy service as an intermediate layer, the processing of subscription requests and unsubscribe messages can be monitored and managed. If an exception or error occurs, the proxy service can take corresponding measures to recover or alarm, thereby enhancing the reliability and stability of the system.

[0156] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.

[0157] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0158] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0159] In the several embodiments provided in the present application, it should be understood that the disclosed system can be implemented in other ways. For example, the system embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of the system or unit can be electrical or other forms.

[0160] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0161] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0162] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially 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, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program code.

[0163] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, which can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0164] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

[0165] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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] It will be easily understood by those skilled in the art that the above description is only 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 in the protection scope of the present invention.

Claims

1. A publish-subscribe method under multiple processors, comprising a subscriber and a publisher under multiple processors, characterized in that: include: The proxy service in the processor forwards the generated subscription request message to the publisher to establish a subscriber list, and generates a subscription response message to feed back to the corresponding subscriber; If the data message changes or a new subscriber appears, the proxy service in the processor sends the data message to the corresponding subscriber in the subscriber list; If the subscriber needs to cancel the subscription, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message.

2. The publish-subscribe method under multiple processors as claimed in claim 1, characterized in that: The proxy service in the processor forwards the generated subscription request message to the publisher to establish a subscriber list, and generates a subscription response message to feed back to the corresponding subscriber, and also includes: The subscription request message includes the subscription data type, subscriber ID and publisher ID; Determine the processor ID of the publisher according to the publisher ID, and forward the subscription request message 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.

3. The publish-subscribe method under multiple processors as claimed in claim 2, characterized in that: The proxy service in the processor forwards the generated subscription request message to the publisher to establish a subscriber list, and generates a subscription response message to feed back to the corresponding subscriber, and also includes: When the publisher generates the subscription request message, a re-subscription timer is synchronously started; If the publisher does not receive the subscription response message within the subscription timeout period, the publisher resends the subscription request message.

4. The publish-subscribe method under multiple processors as claimed in claim 2, characterized in that: 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 further includes: Obtain the subscriber ID 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 information to be sent, the publisher uploads the data information to be sent to the retransmission queue and starts the retransmission timer; If the subscriber does not receive the to-be-sent data message within the retransmission timeout period, the to-be-sent data information in the retransmission queue is resent.

5. The publish-subscribe method under multiple processors as claimed in claim 4, characterized in that: 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 further includes: When the proxy service receives the data message to be sent, the proxy service stores the data message to be sent into a cache queue; If the cache queue is full, the received data message to be sent is lost.

6. The publish-subscribe method under multiple processors as claimed in claim 1, characterized in that: When the subscriber needs to cancel the subscription, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message, and further includes: The subscription cancellation message includes the subscription data type, subscriber ID and publisher ID; Determine the processor ID of the publisher according to the publisher ID, and forward the subscription cancellation message to the publisher corresponding to the processor through the proxy service; After receiving the subscription cancellation message, the publisher deletes the subscriber ID from the subscriber list corresponding to the subscription data type.

7. The publish-subscribe method under multiple processors as claimed in claim 1, characterized in that: When the subscriber needs to cancel the subscription, the subscription cancellation message is sent to the corresponding publisher through the proxy service in the processor, and the corresponding subscriber is deleted from the subscriber list based on the subscription cancellation message, and further includes: When the publisher generates the subscription cancellation message, the subscription cancellation timer is started synchronously; If the publisher does not receive the cancellation response message within the subscription cancellation time, the subscription cancellation message is resent.

8. A publish-subscribe system under multiple processors, characterized in that: include: A subscription initiation module, which 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 feed back to the corresponding subscriber; A 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 the subscriber needs to cancel the subscription, and delete the corresponding subscriber from the subscriber list based on the subscription cancellation message.

9. A publish-subscribe device under a multi-processor, characterized in that: It comprises at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit executes the steps of the publish-subscribe method under the multi-processor according to any one of claims 1 to 7.

10. A storage medium, characterized in that: It stores a computer program executable by an access authentication device. When the computer program runs on the access authentication device, the access authentication device executes the steps of the publish-subscribe method under a multi-processor according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Scalable publish / subscribe messaging systems and methods

    US20090138572A1

  • Limiting proxy subscription propagation in a publish / subscribe message broker network

    US20090182574A1

  • Message delivery in a message system

    US20170142041A1

  • Dynamic subscription and message routing on a topic between a publishing node and subscribing nodes

    WO2004072800A2

  • Distributed cache publishing and subscription method and system, and apparatus

    WO2024207837A1

Cited By

  • COV proxy method based on BACnet router and router

    CN121728164A