Message queue upgrading method and device, storage medium and electronic equipment
Patent Information
- Application Number
- CN202310395843.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2043-04-13
AI Technical Summary
[0006]本公开的目的在于提供一种消息队列升级方法、消息队列升级装置、存储介质及电子设备,旨在解决消息队列升级对业务影响大的问题
[0019] In some embodiments of this disclosure, when upgrading a first message queue Topic1 of a first format to a second message queue Topic2 of a second format, the message queue upgrade method provided in this disclosure is adopted, mainly divided into the following three stages: Stage 1 is the Topic1 single-active stage, that is, when the first listener is turned on, the Topic1 received by the first listener is written to the database; Stage 2 is the Topic1 and Topic2 co-active stage, that is, the second listener is turned on, and the database is updated based on the Topic1 and Topic2 obtained by the first and second listeners respectively; Stage 3 is the Topic2 single-active stage, that is, the first listener is turned off, Topic1 is taken offline, and only Topic2 is kept running, thus completing the process of upgrading from Topic1 to Topic2. Based on the above method, the message queue Topic can be upgraded and replaced step by step by controlling the first and second listeners without affecting normal operation, ensuring data accuracy while reducing the impact on business, improving system robustness, and achieving seamless upgrade.
Smart Images

Figure CN118796842B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of internet e-commerce technology, specifically to a message queue upgrade method, a message queue upgrade device, a storage medium, and an electronic device. Background Technology
[0002] XML (Extensible Markup Language) is designed to store data; any object can be described using XML. XML message deserialization refers to converting an XML string into an object of a specified type, while XML message serialization refers to converting an object into an XML string.
[0003] Since the deserialization process of converting XML strings into objects of a specified type is relatively time-consuming, order message XML deserialization can be affected during peak order periods of promotional activities, impacting order message processing speed. Therefore, during order serialization, XML can be upgraded to ProtoBuf (Google Protocol Buffer, Google's internal mixed-language data standard), and then the ProtoBuf string can be converted during deserialization, thereby improving system performance and reducing costs.
[0004] The upgrade to ProtoBuf involves changing the order message queue topic, that is, changing it from XML format to ProtoBuf format. However, the existing replacement process is cumbersome and has a significant impact on business data processing and execution, making it impossible to achieve seamless processing.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] The purpose of this disclosure is to provide a message queue upgrade method, message queue upgrade device, storage medium, and electronic device, aiming to solve the problem that message queue upgrades have a significant impact on business operations.
[0007] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0008] According to one aspect of the embodiments of this disclosure, a message queue upgrade method is provided, applied to a listening server, comprising: receiving a message queue issued by a data source server; wherein the message queue includes a first message queue of a first format and a second message queue of a second format; responding to an enable command of a first listener, enabling the first listener to write the first message queue received by the first listener into a database; responding to an enable command of a second listener, enabling the second listener and updating the database based on the first message queue received by the first listener and the second message queue received by the second listener; responding to a disable command of the first listener, disabling the first listener and forwarding the disable command to the database so that the database deletes the first message queue.
[0009] According to some embodiments of this disclosure, based on the foregoing scheme, the method includes: the first message queue is a message queue sent through a pre-release pipeline when the target key field of the message queue is in the pre-release environment whitelist of the data source server; the second message queue is a message queue sent through a production pipeline when the target key field of the message queue is not in the pre-release environment whitelist of the data source server.
[0010] According to some embodiments of this disclosure, based on the foregoing scheme, updating the database based on the first message queue received by the first listener and the second message queue received by the second listener includes: serializing the first message queue and the second message queue with the same message identifier to obtain a first business message and a second business message; configuring a distributed lock based on the first business message and the second business message so that the first listener and the second listener simultaneously compete for the distributed lock; updating the database based on the message queue received by the listener that successfully competes, and discarding the message queue received by the listener that fails to compete.
[0011] According to some embodiments of this disclosure, based on the foregoing scheme, updating the database based on the message queue received by the successful contention listener includes: performing deduplication processing on the message queue received by the successful contention listener to determine whether there is a message queue in the database with the same state as the message queue; if there is a message queue in the database with the same state as the message queue, discarding the message queue; if there is no message queue in the database with the same state as the message queue, writing the message queue into the database.
[0012] According to some embodiments of this disclosure, based on the foregoing scheme, before activating the second listener, the method further includes: obtaining the listening cutoff of the second listener; activating the second listener and controlling the second listener according to the listening cutoff; and responding to a change instruction for the listening cutoff to control the second listener according to the changed listening cutoff.
[0013] According to some embodiments of this disclosure, based on the foregoing scheme, the method further includes: generating a shutdown command for the first listener when the listening cutoff is 100%.
[0014] According to some embodiments of this disclosure, based on the foregoing scheme, after enabling the second listener, the method further includes: performing operational monitoring on updating the database; when the operational monitoring obtains an abnormal result, generating a shutdown command to close the second listener; wherein the abnormal result includes one or more of the following: abnormal data in the second message queue, loss of data in the second message queue, and abnormality of the second listener.
[0015] According to a second aspect of the present disclosure, a message queue upgrade apparatus is provided, comprising: a receiving module, configured to receive a message queue issued by a data source server; wherein the message queue includes a first message queue of a first format and a second message queue of a second format; a first single-active module, configured to activate the first listener in response to an activation command of the first listener, so as to write the first message queue received by the first listener into a database; a dual-active module, configured to activate the second listener in response to an activation command of the second listener, and update the database based on the first message queue received by the first listener and the second message queue received by the second listener; and a second single-active module, configured to deactivate the first listener in response to a deactivation command of the first listener, and forward the deactivation command to the database so that the database deletes the first message queue.
[0016] According to a third aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the message queue upgrade method as described in the above embodiments.
[0017] According to a fourth aspect of the present disclosure, an electronic device is provided, characterized in that it includes: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the message queue upgrade method as described in the above embodiments.
[0018] The exemplary embodiments disclosed herein may have some or all of the following beneficial effects:
[0019] In some embodiments of this disclosure, when upgrading a first message queue Topic1 of a first format to a second message queue Topic2 of a second format, the message queue upgrade method provided in this disclosure is adopted, mainly divided into the following three stages: Stage 1 is the Topic1 single-active stage, that is, when the first listener is turned on, the Topic1 received by the first listener is written to the database; Stage 2 is the Topic1 and Topic2 co-active stage, that is, the second listener is turned on, and the database is updated based on the Topic1 and Topic2 obtained by the first and second listeners respectively; Stage 3 is the Topic2 single-active stage, that is, the first listener is turned off, Topic1 is taken offline, and only Topic2 is kept running, thus completing the process of upgrading from Topic1 to Topic2. Based on the above method, the message queue Topic can be upgraded and replaced step by step by controlling the first and second listeners without affecting normal operation, ensuring data accuracy while reducing the impact on business, improving system robustness, and achieving seamless upgrade.
[0020] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0022] Figure 1 The illustration shows a flowchart of a message queue upgrade method according to an exemplary embodiment of the present disclosure;
[0023] Figure 2 This illustration schematically shows a flowchart of a message queue distribution method from a data source in an exemplary embodiment of this disclosure;
[0024] Figure 3 This illustration schematically shows a flowchart of a dynamic switching strategy for dual configuration centers in an exemplary embodiment of this disclosure;
[0025] Figure 4 The illustration schematically shows a process diagram of a local active-active phase in an exemplary embodiment of the present disclosure;
[0026] Figure 5 The schematic diagram illustrates a flowchart of a single-LOCK concurrent lock strategy in an exemplary embodiment of this disclosure;
[0027] Figure 6 This schematic diagram illustrates the composition of a message queue upgrade system according to an exemplary embodiment of the present disclosure;
[0028] Figure 7 This schematic diagram illustrates the composition of a message queue upgrade apparatus according to an exemplary embodiment of the present disclosure;
[0029] Figure 8 This illustration schematically depicts a computer-readable storage medium according to an exemplary embodiment of the present disclosure;
[0030] Figure 9 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation
[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art.
[0032] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0033] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0034] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0035] The implementation details of the technical solutions of the embodiments of this disclosure are described in detail below.
[0036] Figure 1This illustration schematically depicts a flowchart of a message queue upgrade method according to an exemplary embodiment of this disclosure. Figure 1 As shown, the message queue upgrade method includes steps S101 to S104:
[0037] Step S101: Receive a message queue sent by the data source server; wherein the message queue includes a first message queue in a first format and a second message queue in a second format.
[0038] Step S102: In response to the start command of the first listener, start the first listener to write the first message queue received by the first listener into the database.
[0039] Step S103: In response to the start command of the second listener, start the second listener and update the database based on the first message queue received by the first listener and the second message queue received by the second listener;
[0040] Step S104: In response to the shutdown command of the first listener, the first listener is shut down, and the shutdown command is forwarded to the database so that the database deletes the first message queue.
[0041] In some embodiments of this disclosure, when upgrading a first message queue Topic1 of a first format to a second message queue Topic2 of a second format, the message queue upgrade method provided in this disclosure is adopted, mainly divided into the following three stages: Stage 1 is the Topic1 single-active stage, that is, when the first listener is turned on, the Topic1 received by the first listener is written to the database; Stage 2 is the Topic1 and Topic2 co-active stage, that is, the second listener is turned on, and the database is updated based on the Topic1 and Topic2 obtained by the first and second listeners respectively; Stage 3 is the Topic2 single-active stage, that is, the first listener is turned off, Topic1 is taken offline, and only Topic2 is kept running, thus completing the process of upgrading from Topic1 to Topic2. Based on the above method, the message queue Topic can be upgraded and replaced step by step by controlling the first and second listeners without affecting normal operation, ensuring data accuracy while reducing the impact on business, improving system robustness, and achieving seamless upgrade.
[0042] It should be noted that the message queue upgrade method in this application can consist of three main modules: a data source server, a listener server, and a database. The data source server is responsible for sending messages to the queue, the listener server is responsible for listening to the message queue, and the database is used to store the message queue. Steps S101 to S104 are executed by the listener server.
[0043] The following will describe in more detail the steps of the message queue upgrade method in this example embodiment, with reference to the accompanying drawings and embodiments.
[0044] In step S101, a message queue is received from the data source server; wherein the message queue includes a first message queue in a first format and a second message queue in a second format.
[0045] Specifically, the data source contains various types of business data. Taking the logistics field as an example, this includes order business information such as order submission, order cancellation, payment splitting, and payment not splitting.
[0046] The upgrade process of a message queue (MQ) for a certain type of business data involves two MQ queues: a first message queue (Topic1) in the first format before the upgrade (which can be in XML format) and a second message queue (Topic2) in the second format after the upgrade (which can be in ProtoBuf format).
[0047] Specifically, there is only one data source, managed by the data source server. To adapt to message queue upgrades, different message queues need to be split into two pipelines for forwarding, distinguishing between the pre-production environment corresponding to the first message queue and the production environment corresponding to the second message queue.
[0048] Therefore, in one embodiment of this disclosure, in step S101, the first message queue is a message queue sent through the pre-release pipeline when the target key field of the message queue is in the pre-release environment whitelist of the data source server; the second message queue is a message queue sent through the production pipeline when the target key field of the message queue is not in the pre-release environment whitelist of the data source server.
[0049] Specifically, the data source server sets a key field in the MQ message as a whitelist for the pre-release environment. The message is then matched against the whitelist and distributed to both the pre-release and production pipelines. If the message is in the whitelist, the first message queue is sent to the pre-release pipeline; otherwise, it is sent to the production pipeline.
[0050] For example, taking bill of lading messages as an example, firstly, the bill of lading user PIN (Personal Identification Number) is set as a whitelist. Secondly, a whitelist of pre-release environments is maintained in the configuration center. Messages that meet the conditions of the whitelist PIN list will be diverted to the pre-release pipeline, while other messages will be diverted to the production pipeline.
[0051] Figure 2This illustration schematically depicts a flowchart of a message queue distribution method from a data source according to an exemplary embodiment of this disclosure. (Reference) Figure 2 As shown, a whitelist of PINs for the pre-release environment is maintained in the configuration center. When the data source sends MQ, the whitelist-based message distribution processor distributes the first message queue to pipe 1 (pre-release pipe) to build the pre-release environment, and distributes the second message queue to pipe 2 (production pipe) to build the production environment.
[0052] Of course, those skilled in the art will know that a production environment whitelist can also be configured. If the data is in the production environment whitelist, it will be sent to the production pipeline; if it is not in the production environment whitelist, it will be sent to the pre-release pipeline.
[0053] Based on the above method, by adjusting the whitelist of the pre-release environment in the configuration center, a single data source with dual pipeline distribution can be achieved, while the upgrade process can be run and tested in advance in the pre-release environment.
[0054] In step S102, in response to the start command of the first listener, the first listener is started so as to write the first message queue received by the first listener into the database.
[0055] In one embodiment of this disclosure, after the whitelist-based traffic splitting trial and error, before the production environment goes live, different stages of the message queue upgrade method can be controlled through the configuration center.
[0056] Figure 3 This illustration schematically depicts a flow diagram of a dynamic switching strategy for dual configuration centers according to an exemplary embodiment of this disclosure. (See reference...) Figure 3 As shown, the configuration center allows you to set control switches for two listeners: S1 controls the first listener (Listener1) for Topic1; S2 controls the second listener (Listener2) for Topic2. Enabling a listener enables message consumption; disabling a listener prevents message consumption.
[0057] refer to Figure 3 As shown, a cut-off control switch for the second listener control switch S2 can also be set in the configuration center. This switch is used to control the cut-off of Listener2 when S1 and S2 are both turned on, so as to gradually connect the message Topic2 of the newly connected business process, ensure stable operation, and improve the stability of the system.
[0058] In the message queue upgrade method, the first stage is Topic1 single-active, that is, there is only the first message queue Topic1 in the system.
[0059] In the first phase, the user can activate the first listener. After receiving the activation command for the first listener S1, the system controls the activation of Listener1. The data source flows to the first pre-filter Filter1, and then forwards it to the first message queue Topic1. Listener1 listens for Topic1 sent by the data source. After obtaining Topic1, it executes subsequent business processes based on Topic1, such as configuration center-configured consumption and idempotent verification, thereby converting Topic1 into the message required by the business, and writing it to the database after successful verification.
[0060] In step S103, in response to the start command of the second listener, the second listener is started, and the database is updated based on the first message queue received by the first listener and the second message queue received by the second listener.
[0061] In one embodiment of this disclosure, after Topic1 has been running in a single-active state for a period of time, it can enter a dual-active state where Topic1 and Topic2 are located in the same city. The user starts a second listener. When the system receives the start command of the first listener S2, it controls the start of Listener2, thereby listening to Topic2 sent by the data source.
[0062] At this point, the system contains both Topic1 and Topic2, where Topic2 contains messages from newly integrated business processes. The two message queues, Topic1 and Topic2, run concurrently with identical content. Ensuring idempotency and preventing data conflicts is a key challenge in the active-active phase within the same city. Therefore, this disclosed message queue upgrade method provides a single-LOCK concurrent lock strategy to guarantee idempotency while implementing parallel operation of the two queues.
[0063] Therefore, the specific steps in step S103 of updating the database based on the first message queue and the second message queue include: serializing the first message queue and the second message queue with the same message identifier to obtain the first business message and the second business message; configuring a distributed lock based on the first business message and the second business message so that the first listener and the second listener compete for the distributed lock simultaneously; updating the database based on the message queue received by the listener that wins the competition, and discarding the message queue received by the listener that loses the competition.
[0064] Specifically, a distributed lock is configured so that Topic1 and Topic2 compete simultaneously. Business operations are executed according to the Topic that wins the competition, thus ensuring that only one Topic is used for writing data, thereby guaranteeing the stability of business operations.
[0065] In one embodiment of this disclosure, updating the database based on the message queue received by the successful contention listener includes: performing deduplication processing on the message queue received by the successful contention listener to determine whether there is a message queue in the database with the same state as the message queue; if there is a message queue in the database with the same state as the message queue, discarding the message queue; if there is no message queue in the database with the same state as the message queue, writing the message queue into the database.
[0066] Specifically, before the data is entered into the database, a database deduplication process is required. If the database already contains the order and the status is consistent, it is considered a duplicate message and discarded; otherwise, the data is entered into the database according to the business logic.
[0067] Figure 4 This illustration schematically depicts a flowchart of a single-LOCK concurrent lock strategy according to an exemplary embodiment of this disclosure. Specifically, the message queue is an order number, the first message queue Topic1 is in XML format, and the second message queue Topic2 is in ProtoBuf format. (See reference...) Figure 4 As shown, Topic1 uses XML serialization, while Topic2 uses ProtoBuf serialization. After serialization, the order number is obtained, and the JimDB service uses the SET NX (set if not exists) command to set a distributed lock based on the order number. While Topic1 and Topic2 are running simultaneously, they compete for the same distributed lock. If the competition is successful, the message is processed for database entry; otherwise, it is discarded. Taking Topic2's successful acquisition as an example, a database deduplication verification step is added before database entry processing. After successful deduplication verification, database entry processing is then executed.
[0068] Figure 5 This illustration schematically depicts a process diagram of a local active-active phase in an exemplary embodiment of this disclosure. (See reference...) Figure 5 As shown, in the active-active phase within the same city: After receiving the order business message, Topic1 and Topic2 are obtained through MqFilter1 and MqFilter2 respectively. The content of the two topics is exactly the same, only the serialization method is different: Topic1 is in XML format, and Topic2 is in ProtoBuf format. Then, the message is consumed by Listener 1 and Listener 2 respectively. The configuration center configures both Listener 1 and Listener 2 to be enabled, obtaining data serialized in XML and ProtoBuf formats respectively. Then, the corresponding business logic is used to execute JIMDB distributed lock verification and execute the SET NX command. The two listeners compete for the same lock to avoid duplicate processing during parallel consumption. Then, DB anti-duplicate processing is performed, that is, after acquiring the lock, a second DB verification is performed to avoid final duplicate processing. Finally, the data is added or updated in the database.
[0069] In one embodiment of this disclosure, before activating the second listener, the method further includes: obtaining the listening cutoff of the second listener; activating the second listener and controlling the second listener according to the listening cutoff; and responding to a change instruction for the listening cutoff to control the second listener according to the changed listening cutoff.
[0070] Specifically, during the active-active phase of Topic1 and Topic2 within the same city, the control can be achieved by setting the hash rate of the second listener. The rate of change is a process of gradually opening or increasing the rate, for example, running at a rate of 1%, 2%, 5%, 10%, 20%, and 50%. By gradually increasing the number of new messages received in Topic2, the stability of the business operation can be ensured.
[0071] In terms of operation, refer to Figure 3 As shown, since the cut-off control switch of the second listener control switch S2 can be set in the configuration center, the listening cut-off can be configured through the cut-off control switch, and then the second listener can be controlled according to the listening cut-off.
[0072] In one embodiment of this disclosure, after enabling the second listener, the method further includes: performing runtime monitoring on updating the database; and disabling the second listener when runtime monitoring results in an abnormal result; wherein the abnormal result includes one or more of the following: abnormal data in the second message queue, loss of data in the second message queue, and abnormality of the second listener.
[0073] Specifically, Topic2 is a message for newly integrated business processes. When the system is unstable, a contingency plan can be implemented to downgrade and switch back to Topic1 single-active mode for a short period of time to stop the loss immediately.
[0074] Therefore, it is necessary to monitor the database update process. If monitoring detects abnormalities in Topic2 data, such as missing parts, incorrect format, garbled characters, or data loss, or if Listener2 is abnormal, causing abnormalities in the business operation, enabling Topic2 may affect the business logic. In this case, a command to close the second listener can be generated to close the second listener, keeping Topic1 active. After manually handling the abnormal logic, Topic2 can be turned on again via a switch.
[0075] Based on the above methods, it is possible to ensure that a contingency plan is implemented to mitigate operational anomalies, thereby guaranteeing the stability of the system during the MQ upgrade process.
[0076] Step S104: In response to the shutdown command of the first listener, the first listener is shut down, and the shutdown command is forwarded to the database so that the database deletes the first message queue.
[0077] Specifically, after running for a period of time in the same-city active-active phase, the first listener can be turned off. At this time, the first listener will no longer listen to Topic1, so that only Topic2 is in the system. At the same time, Topic1 is taken offline, and only Topic2 is kept running in the system, thus completing the seamless upgrade of MQ.
[0078] The command to shut down the first listener can be generated by user interaction. For example, if the active-active process in the second phase has been running for a period of time, and both Topic1 and Topic2 have traffic and the business process is running smoothly, then the first listener can be shut down.
[0079] The shutdown command for the first listener can also be automatically generated. In one embodiment of this disclosure, the method further includes: shutting down the first listener when the listening load is 100%, and updating the database according to the second message queue received by the second listener.
[0080] Specifically, if the second listener is controlled by the listener cutoff, setting the listener cutoff to 100% means turning off the first listener, and a shutdown command for the first listener can be automatically generated. At this point, only Topic2 exists in the system, and the process of configuring consumption and verifying idempotency through the configuration center continues, thereby inserting or updating the database DB.
[0081] Then, the shutdown command is forwarded to the database. After receiving the shutdown command, the database deletes the first message queue Topic1 that was previously written, which means deleting the XML, so as to ensure that only ProtoBuf remains in the database, thus changing the data from XML format to ProtoBuf format.
[0082] Figure 6 This diagram schematically illustrates the composition of a message queue upgrade system according to an exemplary embodiment of this disclosure. (Reference) Figure 6As shown, taking the logistics field as an example, the data layer mainly handles various order-related tasks, such as order submission, order cancellation, payment splitting, and payment without splitting. The message queue layer consists of Topic1 (XML) and Topic2 (ProtoBuf); the listener layer is divided into first and second listeners for various order-related tasks; the configuration center is responsible for controlling the activation or deactivation of Topic1, the blacklist or whitelist of Topic1, and the activation or deactivation of Topic2, as well as the blacklist or whitelist of Topic2; the idempotent processing layer mainly performs the execution logic for generating distributed locks using SET NX and preventing database duplication; finally, there is the database layer, which handles various types of databases, such as MS SQL, MySQL, and Oracle.
[0083] In summary, the message queue upgrade method disclosed herein provides an active-active model for MQ upgrades within the same city. It achieves dynamic MQ upgrades from the original single-active model to a dual-active model within the same city, and then to a new single-active model. Simultaneously, it employs whitelist-based traffic splitting, dynamic switching with dual switches, and a single lock to guarantee business idempotency, ensuring stability during the dynamic upgrade process. This ensures data accuracy while minimizing the impact on business operations, improving system robustness, and achieving seamless upgrades.
[0084] Figure 7 This schematic diagram illustrates the composition of a message queue upgrade apparatus according to an exemplary embodiment of this disclosure. Figure 7 As shown, the message queue upgrade device 700 may include a distribution module 701, a first single-active module 702, a dual-active module 703, and a second single-active module 704. Wherein:
[0085] The delivery module 701 is used to receive message queues delivered by the data source server; wherein, the message queues include a first message queue in a first format and a second message queue in a second format.
[0086] The first active module 702 is used to respond to the start command of the first listener, start the first listener, and write the first message queue received by the first listener into the database.
[0087] The dual-active module 703 is used to respond to the start command of the second listener, start the second listener, and update the database based on the first message queue received by the first listener and the second message queue received by the second listener;
[0088] The second single-active module 704 is used to close the first listener in response to the close command of the first listener, and forward the close command to the database so that the database deletes the first message queue.
[0089] According to an exemplary embodiment of this disclosure, the first message queue is a message queue sent through the pre-release pipeline when the target key field of the message queue is in the pre-release environment whitelist of the data source server; the second message queue is a message queue sent through the production pipeline when the target key field of the message queue is not in the pre-release environment whitelist of the data source server.
[0090] According to an exemplary embodiment of this disclosure, the dual-active module 703 is further configured to serialize a first message queue and a second message queue having the same message identifier to obtain a first business message and a second business message; configure a distributed lock according to the first business message and the second business message so that the first listener and the second listener compete for the distributed lock simultaneously; update the database based on the message queue received by the listener that wins the competition, and discard the message queue received by the listener that fails the competition.
[0091] According to an exemplary embodiment of this disclosure, the dual-active module 703 is further configured to perform deduplication processing on the message queue received by the listener that has successfully competed for the message queue, so as to determine whether there is a message queue in the database that has the same state as the message queue; if there is a message queue in the database that has the same state as the message queue, the message queue is discarded; if there is no message queue in the database that has the same state as the message queue, the message queue is written into the database.
[0092] According to an exemplary embodiment of this disclosure, the message queue upgrade device 700 further includes a segmentation control module, configured to acquire the listening segmentation of the second listener; enable the second listener and control the second listener according to the listening segmentation; and respond to a change instruction for the listening segmentation to control the second listener according to the changed listening segmentation.
[0093] According to an exemplary embodiment of this disclosure, the slicing control module is further configured to perform operational monitoring on updating the database; when the operational monitoring obtains an abnormal result, it generates a shutdown command to close the second listener; wherein the abnormal result includes one or more of the following: abnormal data in the second message queue, loss of data in the second message queue, and abnormality of the second listener.
[0094] The specific details of each module in the aforementioned message queue upgrade device 700 have been described in detail in the corresponding message queue upgrade method, so they will not be repeated here.
[0095] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0096] In an exemplary embodiment of this disclosure, a storage medium capable of implementing the above-described method is also provided. Figure 8 This schematic diagram illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure, such as... Figure 8 As shown, a program product 800 for implementing the above-described method according to an embodiment of the present disclosure is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a mobile phone. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0097] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided. Figure 9 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure.
[0098] It should be noted that, Figure 9 The computer system 900 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0099] like Figure 9 As shown, the computer system 900 includes a Central Processing Unit (CPU) 901, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 902 or programs loaded from storage section 908 into Random Access Memory (RAM) 903. The RAM 903 also stores various programs and data required for system operation. The CPU 901, ROM 902, and RAM 903 are interconnected via a bus 904. An Input / Output (I / O) interface 905 is also connected to the bus 904.
[0100] The following components are connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to I / O interface 905 as needed. Removable media 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 910 as needed so that computer programs read from them can be installed into storage section 908 as needed.
[0101] In particular, according to embodiments of this disclosure, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by central processing unit (CPU) 901, it performs various functions defined in the system of this disclosure.
[0102] It should be noted that the computer-readable medium shown in the embodiments of this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0103] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0104] The units described in the embodiments of this disclosure can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the unit itself.
[0105] In another aspect, this disclosure also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to perform the methods described in the above embodiments.
[0106] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0107] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this disclosure.
[0108] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure 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 disclosed herein.
[0109] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A message queue upgrade method, characterized in that, include: Receive message queues sent by the data source server; wherein, the message queues include a first message queue in a first format and a second message queue in a second format; In response to the start command of the first listener, the first listener is started so as to write the first message queue received by the first listener into the database; In response to the start command of the second listener, the second listener is started, and the first message queue with the same message identifier and the second message queue received by the second listener are serialized to obtain the first business message and the second business message respectively; a distributed lock is configured according to the first business message and the second business message so that the first listener and the second listener compete for the distributed lock simultaneously; the database is updated based on the message queue received by the listener that wins the competition, and the message queue received by the listener that loses the competition is discarded; In response to the shutdown command of the first listener, the first listener is shut down, and the shutdown command is forwarded to the database so that the database deletes the first message queue.
2. The message queue upgrade method according to claim 1, characterized in that, The method includes: The first message queue is a message queue that is sent through the pre-release pipeline when the target key field of the message queue is in the pre-release environment whitelist of the data source server; The second message queue is a message queue that is sent through the production pipeline when the target key field of the message queue is not in the pre-release environment whitelist of the data source server.
3. The message queue upgrade method according to claim 1, characterized in that, The message queue received by the listener based on the successful contention updates the database, including: The message queue received by the successfully contested listener is subjected to deduplication processing to determine whether there is a message queue in the database with the same state as the message queue. If a message queue with the same status as the message queue exists in the database, the message queue shall be discarded. If no message queue with the same status as the message queue exists in the database, the message queue is written into the database.
4. The message queue upgrade method according to claim 1, characterized in that, Before activating the second listener, the method further includes: Obtain the listening segment of the second listener; Enable the second listener and control the second listener according to the listener cutoff; and In response to the change instruction for the listening cutoff, the second listener is controlled according to the changed listening cutoff.
5. The message queue upgrade method according to claim 4, characterized in that, The method further includes: When the listening cutoff is 100%, a shutdown command for the first listener is generated.
6. The message queue upgrade method according to claim 1, characterized in that, After enabling the second listener, the method further includes: Perform runtime monitoring on the updated database; When the monitoring results in an abnormal operation, a shutdown command is generated to close the second listener; wherein the abnormal result includes one or more of the following: abnormal data in the second message queue, loss of data in the second message queue, and abnormality of the second listener.
7. A message queue upgrade device, characterized in that, include: A receiving module is used to receive message queues sent by a data source server; wherein, the message queues include a first message queue in a first format and a second message queue in a second format; The first active module is used to respond to the start command of the first listener, start the first listener, and write the first message queue received by the first listener into the database. The dual-active module is used to respond to the start command of the second listener, start the second listener, serialize the first message queue with the same message identifier and the second message queue received by the second listener to obtain the first business message and the second business message respectively; configure a distributed lock according to the first business message and the second business message so that the first listener and the second listener compete for the distributed lock simultaneously; update the database based on the message queue received by the listener that wins the competition, and discard the message queue received by the listener that loses the competition. The second single-active module is used to respond to the shutdown command of the first listener, shut down the first listener, and forward the shutdown command to the database so that the database deletes the first message queue.
8. A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the message queue upgrade method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the message queue upgrade method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data migration method and device based on message queue, equipment and medium
CN115374086A