CN114637611A - Information processing method and device based on message queue and computer equipment - Google Patents

Information processing method and device based on message queue and computer equipment Download PDF

Info

Publication number
CN114637611A
CN114637611A CN202210237120.8A CN202210237120A CN114637611A CN 114637611 A CN114637611 A CN 114637611A CN 202210237120 A CN202210237120 A CN 202210237120A CN 114637611 A CN114637611 A CN 114637611A
Authority
CN
China
Prior art keywords
message
transaction
transaction message
node
message queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210237120.8A
Other languages
Chinese (zh)
Inventor
李陈
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202210237120.8A priority Critical patent/CN114637611A/en
Publication of CN114637611A publication Critical patent/CN114637611A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

The embodiment of the application belongs to the technical field of cloud, and relates to a message queue-based information processing method, a message queue-based information processing device, computer equipment and a storage medium, wherein the method comprises the following steps: receiving a transaction message sent by a producer node; when the message state identifier of the transaction message is a standing identifier, adding the transaction message into a standing message queue which cannot be consumed by the consumer node; receiving transaction processing result information sent by a producer node, wherein the transaction processing result information is generated by the producer node according to a processing result of a transaction message; and when the producer node is determined to pass the transaction message processing according to the transaction processing result information, the message state identifier is modified into a processable identifier, and the transaction message is transferred to a to-be-processed message queue which can be consumed by the consumer node. In addition, the application also relates to a block chain technology, and transaction result information can be stored in the block chain. The method and the device realize the consistency of data among different nodes in the distributed system.

Description

Information processing method and device based on message queue and computer equipment
Technical Field
The present application relates to the field of cloud technologies, and in particular, to a method and an apparatus for processing information based on a message queue, a computer device, and a storage medium.
Background
A message queue is a container that holds messages during their transmission, and acts as a "man-in-the-middle" to relay messages from a message source to a destination. Message queues are often used in distributed systems, and when one system needs to interact with multiple systems, message queues are often used to achieve decoupling between the systems. One system sends a message to the message queue and then other systems consume the message in the message queue, and the system processes data for the message. If the systems on both sides of the message queue fail, causing a processing error of one party to the message, data inconsistency may occur in each system. Currently, however, there is no effective means to address this data inconsistency.
Disclosure of Invention
An embodiment of the present application aims to provide a message queue-based information processing method, an apparatus, a computer device, and a storage medium, so as to solve the technical problem of inconsistent messages in a distributed system.
In order to solve the above technical problem, an embodiment of the present application provides an information processing method based on a message queue, which adopts the following technical solutions:
receiving a transaction message sent by a producer node;
when detecting that the message state identifier in the transaction message is a standing identifier, adding the transaction message into a standing message queue, wherein the transaction message in the standing message queue cannot be consumed by a consumer node; and
receiving transaction processing result information sent by the producer node, wherein the transaction processing result information is generated by the producer node according to a processing result of the transaction message;
and when the producer node is determined to pass the transaction message processing according to the transaction processing result information, the message state identifier is modified into a processable identifier, the transaction message is transferred to a message queue to be processed, and the transaction message in the message queue to be processed can be consumed by a consumer node.
In order to solve the above technical problem, an embodiment of the present application further provides an information processing apparatus based on a message queue, which adopts the following technical solutions:
the transaction message receiving module is used for receiving the transaction message sent by the producer node;
the static adding module is used for adding the transaction message into a static message queue when detecting that the message state identifier in the transaction message is a static identifier, wherein the transaction message in the static message queue cannot be consumed by a consumer node; and
a result information receiving module, configured to receive transaction result information sent by the producer node, where the transaction result information is generated by the producer node according to a processing result of the transaction message;
and the message transfer module is used for modifying the message state identifier into a processable identifier and transferring the transaction message to a to-be-processed message queue when the producer node is determined to pass the transaction message processing according to the transaction result information, wherein the transaction message in the to-be-processed message queue can be consumed by the consumer node.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:
receiving a transaction message sent by a producer node;
when detecting that the message state identifier in the transaction message is a standing identifier, adding the transaction message into a standing message queue, wherein the transaction message in the standing message queue cannot be consumed by a consumer node; and
receiving transaction processing result information sent by the producer node, wherein the transaction processing result information is generated by the producer node according to a processing result of the transaction message;
and when the producer node is determined to pass the transaction message processing according to the transaction processing result information, the message state identifier is modified into a processable identifier, the transaction message is transferred to a to-be-processed message queue, and the transaction message in the to-be-processed message queue can be consumed by a consumer node.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:
receiving a transaction message sent by a producer node;
when detecting that the message state identifier in the transaction message is a standing identifier, adding the transaction message into a standing message queue, wherein the transaction message in the standing message queue cannot be consumed by a consumer node; and
receiving transaction processing result information sent by the producer node, wherein the transaction processing result information is generated by the producer node according to a processing result of the transaction message;
and when the producer node is determined to pass the transaction message processing according to the transaction processing result information, the message state identifier is modified into a processable identifier, the transaction message is transferred to a to-be-processed message queue, and the transaction message in the to-be-processed message queue can be consumed by a consumer node.
Compared with the prior art, the embodiment of the application mainly has the following beneficial effects: reconstructing the transaction message and the message queue, and adding a message state identifier to the transaction message, wherein the message state identifier is used for identifying whether the transaction message can be consumed by a consumer node; two parallel message queues can be arranged, and transaction messages which cannot be consumed and transaction messages which can be consumed are stored respectively; when detecting that the message state identifier in the transaction message sent by the producer node is a static identifier which can not be consumed, adding the transaction message into a static message queue; the producer node can generate transaction processing result information according to the processing result of the transaction message; if the message queue server determines that the producer node passes the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier which represents that the transaction message can be consumed, and the transaction message is transferred to a message queue to be processed so that the consumer node can consume the transaction message; the method and the device control the processing process of the transaction message through the message state identifier and the two message queues, and ensure the consistency of data among different nodes.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a message queue-based information processing method according to the present application;
FIG. 3 is a schematic diagram of an embodiment of a message queue based information processing apparatus according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the foregoing drawings are used for distinguishing between different objects and not for describing a particular sequential order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, the system architecture 100 may include end devices 101, 102, producer nodes 103, 104, a network 105, a message queue server 106, and a consumer node 107. The network 105 serves to provide a medium for communication links between the terminal devices 101, 102, the producer nodes 103, 104, the message queue server 106 and the consumer node 107. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may use the terminal devices 101, 102 to interact with the producer nodes 103, 104 over the network 105 to receive or send messages or the like. The terminal devices 101 and 102 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101 and 102 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The producer nodes 103, 104 may be servers providing services, such as background servers providing support for pages displayed on the terminal devices 101, 102.
It should be noted that the message queue-based information processing method provided in the embodiment of the present application is generally executed by a message queue server, and accordingly, the message queue-based information processing apparatus is generally disposed in the message queue server.
It should be understood that the number of terminal devices, networks, message queue servers, producer nodes, and consumer nodes in fig. 1 are merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation.
With continuing reference to FIG. 2, a flowchart of one embodiment of a message queue-based information processing method according to the present application is shown. The information processing method based on the message queue comprises the following steps:
step S201, receiving a transaction message sent by a producer node.
In this embodiment, an electronic device (for example, the message queue server shown in fig. 1) on which the message queue based information processing method operates may communicate with the producer node or the consumer node through a wired connection manner or a wireless connection manner. It should be noted that the wireless connection means may include, but is not limited to, a 3G/4G/5G connection, a WiFi connection, a bluetooth connection, a WiMAX connection, a Zigbee connection, a uwb (ultra wideband) connection, and other wireless connection means now known or developed in the future.
Specifically, the transaction message is a message for recording a transaction, is generated by the producer node, and is sent to the message queue server. For example, when a user purchases a commodity a in an app (application), a producer node supporting the app to run generates a transaction message according to the purchase behavior of the commodity a by the user, and then sends the transaction message to the message queue server.
Step S202, when the message state identifier in the transaction message is detected to be the standing identifier, the transaction message is added into a standing message queue, and the transaction message in the standing message queue can not be consumed by the consumer node.
Specifically, the transaction message has a message status identifier, and the message status identifier is used to identify whether the transaction message can be currently consumed by the consumer node. The message state identifier comprises a standing identifier and a processable identifier; when the message state identifier is a standing identifier, the transaction message can not be consumed by the consumer node for the moment; when the message state identifier is a processable identifier, it indicates that the transaction message can be consumed by the consumer node.
The producer node also needs to process the transaction message, so as to avoid the failure of the producer node in processing the transaction message and the error accumulation caused by the fact that the subsequent consumer nodes continue to process the transaction message, the message state identifier in the transaction message sent to the message queue server by the producer node is a standing identifier.
The message queue server can set two message queues, wherein one message queue is a standing message queue and is used for storing the transaction message with the message state identifier as the standing identifier; the other message queue is a pending message queue for storing transaction messages whose message status is identified as a processable identification.
When the message state identifier in the transaction message is a standing identifier, adding the transaction message into a standing message queue; the consumer node is not aware of the transaction message in the standing message queue, and cannot consume the transaction message in the standing message queue.
Step S203, receiving the transaction result information sent by the producer node, wherein the transaction result information is generated by the producer node according to the processing result of the transaction message.
Specifically, the producer node may also process the local transaction message to obtain a processing result, generate transaction result information according to the processing result, and then send the transaction result information to the message queue server. For example, when the producer node is an order system, the order system needs to create an order corresponding to the transaction message in an order database, and generate transaction result information according to whether the order is created successfully.
It is emphasized that, in order to further ensure the privacy and security of the transaction result information, the transaction result information may also be stored in a node of a block chain. So as to carry out information check subsequently according to the transaction result information in the block chain node.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
And step S204, when the producer node is determined to pass the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier, the transaction message is transferred to a to-be-processed message queue, and the transaction message in the to-be-processed message queue can be consumed by the consumer node.
In particular, the transaction flow may advance when it is determined from the transaction result information that the producer node passed through the transaction message processing. And the message queue server modifies the message state identifier into a processable identifier and then transfers the transaction message to the to-be-processed message queue so that the consumer node consumes the transaction message in the to-be-processed message queue.
For example, when the order corresponding to the transaction message is determined to be established in the order database according to the transaction result information, the message queue server transfers the transaction message to the message queue to be processed. And the inventory system serving as the consumer node takes the transaction message from the message queue to be processed for consumption, and subtracts 1 from the inventory database.
In the embodiment, the transaction message and the message queue are reconstructed, and the message state identifier is added to the transaction message and used for identifying whether the transaction message can be consumed by a consumer node; two parallel message queues can be arranged, and transaction messages which cannot be consumed and transaction messages which can be consumed are stored respectively; when detecting that the message state identifier in the transaction message sent by the producer node is a static identifier which can not be consumed, adding the transaction message into a static message queue; the producer node can generate transaction processing result information according to the processing result of the transaction message; if the message queue server determines that the producer node passes the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier which represents that the transaction message can be consumed, and the transaction message is transferred to a message queue to be processed so that the consumer node can consume the transaction message; the method and the device control the processing process of the transaction message through the message state identifier and the two message queues, and ensure the consistency of data among different nodes.
Further, after the step S202, the method may further include: acquiring the received duration of the transaction message; and when the received duration exceeds the preset duration and the transaction processing result information is not received, sending a processing result verification instruction to the producer node, wherein the processing result verification instruction is used for indicating the producer node to verify the processing result of the transaction information and generating the transaction processing result information according to the processing result.
Specifically, because a producer node needs a certain time to process the transaction message, generate the transaction result information, and send the transaction result information, the message queue server starts timing after receiving the transaction message, and the recorded duration is the received duration.
The message queue server obtains the received time length, when the received time length exceeds the preset time length and the transaction result information is not received yet, a processing result verification instruction can be generated, and the processing result verification instruction is sent to the producer node. The producer node can obtain the processing result of the producer node on the transaction message according to the processing result checking instruction, generate transaction processing result information according to the processing result, and send the transaction processing result information to the message queue server.
In this embodiment, when the received duration exceeds the preset duration and the transaction result information is not yet received, a processing result check instruction is sent to the producer node to obtain the transaction result information, so as to advance the processing of the transaction flow.
Further, after the step of obtaining the received duration of the transaction message, the method may further include: when the received time length exceeds the preset time length and the transaction result information is not received, selecting a second producer node in a distributed system where the producer node is located; and sending a processing result checking instruction to the second producer node, wherein the processing result checking instruction is used for indicating the second producer node to inquire the processing result of the transaction message in the producer database, and generating transaction processing result information according to the processing result.
Specifically, when a plurality of producer nodes exist, the application can obtain the transaction processing result information of the transaction message through other producer nodes without depending on a specific producer node.
A producer may employ a clustered deployment that includes multiple producer nodes, such that there are multiple instances and multiple producer nodes share a producer database. The processing result of the producer node on the transaction message can be obtained through the producer database.
If the producer node does not receive the transaction result information in the preset time length because of network fault, downtime or other reasons, and the producer node cannot communicate with the producer node, other available examples can be searched in the distributed cluster to obtain a second producer node. And then sending a processing result checking instruction aiming at the transaction message to the second producer node, inquiring the processing result of the transaction message in the shared producer database by the second producer node, and generating transaction processing result information according to the processing result.
The producer node may provide a query interface through which the message queue server invokes the producer node to query the results of the processing of the transaction message.
For example, an order system deploys 10 services, and 10 service instances share an order database. The initial transaction message is sent by one of the instances in the cluster. When the instance fails, the message queue server searches the instance capable of normal communication in 10 instances as a second producer node, then the second producer node inquires whether an order associated with the transaction message exists in an order database, and generates transaction processing result information according to the inquiry result.
In this embodiment, other instances may be selected as the second producer node in the distributed system, and the processing result of the transaction message is queried in the producer database through the second producer node, so that it is ensured that the producer node can obtain the transaction processing result information even in the event of a failure.
Further, after step S203, the method may further include: and when the producer node is determined to fail to process the transaction message according to the transaction processing result information, deleting the transaction message from the standing message queue.
Specifically, when it is determined that the producer node fails to process the transaction message according to the transaction result information, it indicates that the previous link of the transaction flow has failed, and the message queue server may delete the transaction message in the standing message queue without performing the next flow.
In the embodiment, when the producer node fails to process the transaction message, the transaction message in the standing message queue is deleted, so that useless transaction messages are cleared, and message backlog is avoided.
Further, after the step S204, the method may further include: acquiring consumption feedback information returned by the consumer node according to the transaction message; and when the consumer node is determined to successfully process the transaction message according to the consumption feedback information, deleting the transaction message from the message queue to be processed.
Specifically, the consumer node reads the transaction message from the message queue to be processed, processes the transaction message, generates a consumption feedback message according to a processing result, and then sends the consumption feedback message to the message queue server. The consumption feedback message may record whether the consumer node successfully or unsuccessfully processes the transaction message.
And when the message queue server determines that the consumer node successfully processes the transaction message according to the consumption feedback information, deleting the transaction message from the message queue to be processed, so that the message backlog is avoided, the operating pressure of the message queue server is reduced, and meanwhile, deleting the transaction message from the message queue to be processed indicates that the processing flow of the transaction message is finished, so that the consumption state of the transaction message in the consumer node is checked.
In one embodiment, the consumption feedback information indicating that the processing is successful may be an ack message (Acknowledgement message).
In this embodiment, when it is determined that the consumer node successfully processes the transaction message according to the consumption feedback information, the transaction message is deleted from the to-be-processed message queue, so that message compression is avoided, and consistency check of the message in the distributed system is also completed.
Further, after the step of obtaining the consumption feedback information returned by the consumer node according to the transaction message, the method may further include: and when the transaction message processing failure of the consumer node is determined according to the consumption feedback message, transferring the transaction message to a retry message queue, wherein the transaction message in the retry message queue is used for the consumer node to consume again.
Specifically, an abnormality may occur when the consumer node processes the transaction message, for example, when the consumer node is an inventory system, the inventory amount of the commodity a needs to be reduced by 1 by the inventory system according to the transaction message, but the inventory amount cannot be updated due to downtime of the inventory system. At this time, the consumer node may generate consumption feedback information indicating a process failure.
After the consumption of the transaction message is failed by the consumer node, a re-consumption retry operation can be performed, and when the number of retry operations reaches a preset threshold value but the transaction message still cannot be successfully processed, the consumer node generates consumption feedback information indicating the processing failure; or when the consumer node still cannot process successfully within the preset time length, generating consumption feedback information indicating processing failure.
For transaction messages that fail to be processed by the consumer node, the message queue server can transfer the transaction message to a retry message queue. The retry message queue is also the message queue in the message queue server. The consumer node can re-acquire the transaction message from the retry message queue through the timing task and consume the transaction message until the transaction message is successfully processed, returns consumption feedback information indicating the successful processing to the message queue server, and then deletes the transaction message from the retry message queue by the message queue server.
In this embodiment, when it is determined that the consumer node fails to process the transaction message according to the consumption feedback message, the transaction message is transferred to the retry message queue, so that the consumer node consumes again, and final consistency of messages in the producer node and the consumer node is ensured.
Further, after the step of obtaining the consumption feedback information returned by the consumer node according to the transaction message, the method may further include: when the consumer node is determined to fail to process the transaction message according to the consumption feedback message, transferring the transaction message to a backup message queue, and instructing the consumer node to store the transaction message in a database, wherein the transaction message in the database is used for being consumed again by the consumer node; and when the transaction message is successfully processed by the consumer node, deleting the transaction message from the backup message queue.
Specifically, when the consumer server fails to process the transaction message, consumption feedback information indicating that the processing fails may be generated and sent to the message queue server. And after receiving the consumption feedback information, the message queue server transfers the transaction message to a backup message queue, wherein the backup message queue is also a message queue in the message queue server and can backup the transaction message so that the consumer node can acquire the transaction message from the backup message queue when needed.
The consumer node can persistently store the transaction message which fails to be processed into the database, then scan the previously unprocessed transaction message in the database through the timing task until the consumption is successful, delete the transaction message from the database, and inform the message queue server of deleting the transaction message in the backup message queue. The extra database is used for storing and processing the failed transaction messages, so that the backlog of the messages in the message queue can be reduced, the persistence characteristic of the database ensures that the transaction messages cannot be lost, the throughput of the database is generally higher than that of the message queue, a large number of transaction messages which cannot be successfully processed can be stored under the extremely abnormal condition, and the final consistency of the messages can be ensured.
In one embodiment, after the consumer node fails to process the transaction message, the transaction message can be directly persisted into the database, and then the transaction message which fails to be processed before is read from the database through the timing task and consumed again until the processing is successful, and the transaction message is deleted from the database.
In this embodiment, when the consumer node fails to process the transaction message, the transaction message may be transferred to a backup message queue for consumption by the consumer node; meanwhile, the consumer node can store the transaction message into the database in a persistent mode so as to carry out consumption again; the double storage of the backup message queue and the database ensures the safety of the transaction message and the final consistency of the message in the distributed system.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an information processing apparatus based on a message queue, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be applied to various electronic devices.
As shown in fig. 3, the message queue-based information processing apparatus 300 according to the present embodiment includes: a transaction message receiving module 301, a standing joining module 302, a result information receiving module 303 and a message transferring module 304, wherein:
a transaction message receiving module 301, configured to receive a transaction message sent by a producer node.
And a standing adding module 302, configured to add the transaction message to a standing message queue when detecting that the message state identifier in the transaction message is a standing identifier, where the transaction message in the standing message queue cannot be consumed by the consumer node.
A result information receiving module 303, configured to receive transaction result information sent by the producer node, where the transaction result information is generated by the producer node according to a processing result of the transaction message.
And the message transfer module 304 is configured to modify the message state identifier into a processable identifier and transfer the transaction message to a to-be-processed message queue when it is determined that the producer node passes the transaction message processing according to the transaction result information, where the transaction message in the to-be-processed message queue can be consumed by the consumer node.
In the embodiment, the transaction message and the message queue are reconstructed, and the message state identifier is added to the transaction message and used for identifying whether the transaction message can be consumed by a consumer node; two parallel message queues can be arranged, and transaction messages which cannot be consumed and transaction messages which can be consumed are stored respectively; when detecting that the message state identifier in the transaction message sent by the producer node is a static identifier which can not be consumed, adding the transaction message into a static message queue; the producer node can generate transaction processing result information according to the processing result of the transaction message; if the message queue server determines that the producer node passes the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier which represents that the transaction message can be consumed, and the transaction message is transferred to a message queue to be processed so that the consumer node can consume the transaction message; the method and the device control the processing process of the transaction message through the message state identifier and the two message queues, and ensure the consistency of data among different nodes.
In some optional implementations of this embodiment, the message queue-based information processing apparatus 300 may further include: duration acquisition module and instruction sending module, wherein:
and the duration acquisition module is used for acquiring the received duration of the transaction message.
And the instruction sending module is used for sending a processing result checking instruction to the producer node when the received time length exceeds the preset time length and the transaction processing result information is not received, wherein the processing result checking instruction is used for indicating the producer node to check the processing result of the transaction information and generating the transaction processing result information according to the processing result.
In this embodiment, when the received duration exceeds the preset duration and the transaction result information is not yet received, a processing result check instruction is sent to the producer node to obtain the transaction result information, so as to advance the processing of the transaction flow.
In some optional implementations of this embodiment, the message queue-based information processing apparatus 300 may further include: node selection module and check instruction sending module, wherein:
and the node selection module is used for selecting a second producer node in the distributed system where the producer node is located when the received time length exceeds the preset time length and the transaction result information is not received.
And the verification instruction sending module is used for sending a processing result verification instruction to the second producer node, wherein the processing result verification instruction is used for indicating the second producer node to inquire the processing result of the transaction message in the producer database and generating transaction processing result information according to the processing result.
In this embodiment, other instances may be selected as the second producer node in the distributed system, and the processing result of the transaction message is queried in the producer database through the second producer node, so that it is ensured that the producer node can obtain the transaction processing result information even in the event of a failure.
In some optional implementations of the embodiment, the message queue based information processing apparatus 300 may further include a static deletion module, and the static deletion module is configured to delete the transaction message from the static message queue when it is determined that the producer node fails to process the transaction message according to the transaction result information.
In the embodiment, when the producer node fails to process the transaction message, the transaction message in the standing message queue is deleted, so that useless transaction messages are cleared, and message backlog is avoided.
In some optional implementations of this embodiment, the message queue-based information processing apparatus 300 may further include: feedback acquisition module and deletion module, wherein:
and the feedback acquisition module is used for acquiring consumption feedback information returned by the consumer node according to the transaction message.
And the deleting module is used for deleting the transaction message from the message queue to be processed when the consumer node is determined to successfully process the transaction message according to the consumption feedback information.
In this embodiment, when it is determined that the consumer node successfully processes the transaction message according to the consumption feedback information, the transaction message is deleted from the to-be-processed message queue, so that message compression is avoided, and consistency check of the message in the distributed system is also completed.
In some optional implementations of this embodiment, the message queue based information processing apparatus 300 may further include a retry transfer module, where the retry transfer module is configured to transfer the transaction message to a retry message queue when it is determined that the consumer node fails to process the transaction message according to the consumption feedback message, and the transaction message in the retry message queue is used for being re-consumed by the consumer node.
In this embodiment, when it is determined that the consumer node fails to process the transaction message according to the consumption feedback message, the transaction message is transferred to the retry message queue, so that the consumer node consumes again, and final consistency of messages in the producer node and the consumer node is ensured.
In some optional implementations of this embodiment, the message queue-based information processing apparatus 300 may further include: backup transfer module and backup delete module, wherein:
and the backup transfer module is used for transferring the transaction message to a backup message queue and indicating the consumer node to store the transaction message into a database when the consumer node is determined to fail to process the transaction message according to the consumption feedback message, wherein the transaction message in the database is used for being consumed again by the consumer node.
And the backup deleting module is used for deleting the transaction message from the backup message queue when the consumer node successfully processes the transaction message.
In this embodiment, when the consumer node fails to process the transaction message, the transaction message may be transferred to a backup message queue for consumption by the consumer node; meanwhile, the consumer node can persistently store the transaction message into the database so as to carry out consumption again; the dual storage of the backup message queue and the database ensures the security of the transaction messages and also ensures the final consistency of the messages in the distributed system.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4, fig. 4 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, and a network interface 43, which are communicatively connected to each other via a system bus. It is noted that only computer device 4 having components 41-43 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 4. Of course, the memory 41 may also include both internal and external storage devices of the computer device 4. In this embodiment, the memory 41 is generally used for storing an operating system installed in the computer device 4 and various types of application software, such as computer readable instructions of a message queue-based information processing method. Further, the memory 41 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute computer readable instructions stored in the memory 41 or process data, for example, execute computer readable instructions of the message queue based information processing method.
The network interface 43 may comprise a wireless network interface or a wired network interface, and the network interface 43 is generally used for establishing communication connection between the computer device 4 and other electronic devices.
The computer device provided in this embodiment may execute the message queue-based information processing method described above. The message queue-based information processing method here may be the message queue-based information processing method of each of the embodiments described above.
In the embodiment, the transaction message and the message queue are reconstructed, and the message state identifier is added to the transaction message and used for identifying whether the transaction message can be consumed by a consumer node; two parallel message queues can be arranged, and transaction messages which cannot be consumed and transaction messages which can be consumed are stored respectively; when detecting that the message state identifier in the transaction message sent by the producer node is a static identifier which can not be consumed, adding the transaction message into a static message queue; the producer node can generate transaction processing result information according to the processing result of the transaction message; if the message queue server determines that the producer node passes the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier which represents that the transaction message can be consumed, and the transaction message is transferred to a message queue to be processed so that the consumer node can consume the transaction message; the method and the device control the processing process of the transaction message through the message state identifier and the two message queues, and ensure the consistency of data among different nodes.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing computer-readable instructions executable by at least one processor to cause the at least one processor to perform the steps of the message queue-based information processing method as described above.
In the embodiment, the transaction message and the message queue are reconstructed, and the message state identifier is added to the transaction message and used for identifying whether the transaction message can be consumed by a consumer node; two parallel message queues can be arranged, and transaction messages which cannot be consumed and transaction messages which can be consumed are stored respectively; when detecting that the message state identifier in the transaction message sent by the producer node is a static identifier which cannot be consumed, adding the transaction message into a static message queue; the producer node can generate transaction processing result information according to the processing result of the transaction message; if the message queue server determines that the producer node passes the transaction message processing according to the transaction result information, the message state identifier is modified into a processable identifier which represents that the transaction message can be consumed, and the transaction message is transferred to a message queue to be processed so that the consumer node can consume the transaction message; the method and the device control the processing process of the transaction message through the message state identifier and the two message queues, and ensure the consistency of data among different nodes.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. An information processing method based on a message queue is characterized by comprising the following steps:
receiving a transaction message sent by a producer node;
when detecting that the message state identifier in the transaction message is a standing identifier, adding the transaction message into a standing message queue, wherein the transaction message in the standing message queue cannot be consumed by a consumer node; and
receiving transaction processing result information sent by the producer node, wherein the transaction processing result information is generated by the producer node according to a processing result of the transaction message;
and when the producer node is determined to pass the transaction message processing according to the transaction processing result information, the message state identifier is modified into a processable identifier, the transaction message is transferred to a to-be-processed message queue, and the transaction message in the to-be-processed message queue can be consumed by a consumer node.
2. The message queue-based information processing method according to claim 1, wherein after the step of adding the transaction message to a standing message queue when detecting that the message status identifier in the transaction message is a standing identifier, the method further comprises:
acquiring the received duration of the transaction message;
and when the received time length exceeds a preset time length and transaction processing result information is not received, sending a processing result verification instruction to the producer node, wherein the processing result verification instruction is used for indicating the producer node to verify the processing result of the transaction information and generating the transaction processing result information according to the processing result.
3. The message queue-based information processing method according to claim 2, further comprising, after the step of obtaining the received duration of the transaction message:
when the received time length exceeds a preset time length and transaction processing result information is not received, selecting a second producer node in a distributed system where the producer node is located;
and sending a processing result checking instruction to the second producer node, wherein the processing result checking instruction is used for indicating the second producer node to inquire the processing result of the transaction message in a producer database and generating transaction processing result information according to the processing result.
4. The message queue-based information processing method according to claim 1, further comprising, after the step of receiving the transaction result information sent by the producer node:
and deleting the transaction message from the standing message queue when the producer node is determined to fail to process the transaction message according to the transaction processing result information.
5. The message queue-based information processing method according to claim 1, wherein after the step of modifying the message status flag to a processable flag and transferring the transaction message to a pending message queue when it is determined that the producer node passed the transaction message processing according to the transaction result information, further comprising:
acquiring consumption feedback information returned by the consumer node according to the transaction message;
and when the consumer node is determined to successfully process the transaction message according to the consumption feedback information, deleting the transaction message from the message queue to be processed.
6. The message queue-based information processing method according to claim 5, further comprising, after the step of obtaining consumption feedback information returned by the consumer node according to the transaction message:
and when the transaction message processing failure of the consumer node is determined according to the consumption feedback message, transferring the transaction message to a retry message queue, wherein the transaction message in the retry message queue is used for the consumer node to consume again.
7. The message queue-based information processing method according to claim 5, further comprising, after the step of obtaining consumption feedback information returned by the consumer node according to the transaction message:
when the consumer node is determined to fail to process the transaction message according to the consumption feedback message, transferring the transaction message to a backup message queue, and instructing the consumer node to store the transaction message in a database, wherein the transaction message in the database is used for being consumed again by the consumer node;
and when the transaction message is successfully processed by the consumer node, deleting the transaction message from the backup message queue.
8. An information processing apparatus based on a message queue, comprising:
the transaction message receiving module is used for receiving the transaction message sent by the producer node;
a standing adding module, configured to add the transaction message to a standing message queue when detecting that a message state identifier in the transaction message is a standing identifier, where the transaction message in the standing message queue cannot be consumed by a consumer node; and
a result information receiving module, configured to receive transaction result information sent by the producer node, where the transaction result information is generated by the producer node according to a processing result of the transaction message;
and the message transfer module is used for modifying the message state identifier into a processable identifier and transferring the transaction message to a to-be-processed message queue when the producer node is determined to pass the transaction message processing according to the transaction result information, wherein the transaction message in the to-be-processed message queue can be consumed by the consumer node.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor which when executed implements the steps of the message queue based information processing method of any one of claims 1 to 7.
10. A computer-readable storage medium, having computer-readable instructions stored thereon, which, when executed by a processor, implement the steps of the message queue-based information processing method according to any one of claims 1 to 7.
CN202210237120.8A 2022-03-11 2022-03-11 Information processing method and device based on message queue and computer equipment Pending CN114637611A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210237120.8A CN114637611A (en) 2022-03-11 2022-03-11 Information processing method and device based on message queue and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210237120.8A CN114637611A (en) 2022-03-11 2022-03-11 Information processing method and device based on message queue and computer equipment

Publications (1)

Publication Number Publication Date
CN114637611A true CN114637611A (en) 2022-06-17

Family

ID=81946945

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210237120.8A Pending CN114637611A (en) 2022-03-11 2022-03-11 Information processing method and device based on message queue and computer equipment

Country Status (1)

Country Link
CN (1) CN114637611A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115379012A (en) * 2022-10-25 2022-11-22 航天云网数据研究院(广东)有限公司 Industrial interconnection platform message queue deployment method and device based on identification analysis
CN116112880A (en) * 2022-11-09 2023-05-12 上海创蓝云智信息科技股份有限公司 MQ-based high concurrency short message sending method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115379012A (en) * 2022-10-25 2022-11-22 航天云网数据研究院(广东)有限公司 Industrial interconnection platform message queue deployment method and device based on identification analysis
CN116112880A (en) * 2022-11-09 2023-05-12 上海创蓝云智信息科技股份有限公司 MQ-based high concurrency short message sending method and device
CN116112880B (en) * 2022-11-09 2023-09-08 上海创蓝云智信息科技股份有限公司 MQ-based high concurrency short message sending method and device

Similar Documents

Publication Publication Date Title
CN111414334B (en) File fragment uploading method, device, equipment and storage medium based on cloud technology
CN111274045B (en) Multi-platform docking method and device, computer equipment and readable storage medium
CN114637611A (en) Information processing method and device based on message queue and computer equipment
CN112035472B (en) Data processing method, device, computer equipment and storage medium
CN112380227A (en) Data synchronization method, device and equipment based on message queue and storage medium
CN110895472A (en) Method and device for identifying service change
CN111338834B (en) Data storage method and device
CN113254445A (en) Real-time data storage method and device, computer equipment and storage medium
CN115455058A (en) Cache data processing method and device, computer equipment and storage medium
CN109088914B (en) Block generation method, block chain ecosystem and computer readable storage medium
CN107657155B (en) Method and device for authenticating user operation authority
CN110765131B (en) Data compression method and device for goods source data, computer equipment and storage medium
CN112969198A (en) Data transmission method, terminal and storage medium
CN111679892A (en) Distributed transaction processing method, device, equipment and medium
CN114449040B (en) Configuration issuing method and device based on cloud platform
CN108428182B (en) Development platform device, method for acquiring policy number, and computer-readable storage medium
CN114143308A (en) File uploading information processing method and device, computer equipment and storage medium
CN115330396A (en) Payment state acquisition method and device, computer equipment and storage medium
CN114968822A (en) Interface testing method and device, computer equipment and storage medium
CN114615325A (en) Message pushing method and device, computer equipment and storage medium
CN114048718A (en) Table data processing method and device, computer equipment and storage medium
CN112632192A (en) Node maintenance method and device, computer equipment and medium
CN112749124A (en) Page information management method and device, computer equipment and readable storage medium
CN114650252B (en) Routing method and device based on enterprise service bus and computer equipment
CN111581446B (en) Graph relation generation method, device, system, equipment and storage medium

Legal Events

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