CN114237823A - Message queue exception handling method and device, computer equipment and storage medium - Google Patents
Message queue exception handling method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN114237823A CN114237823A CN202111554910.0A CN202111554910A CN114237823A CN 114237823 A CN114237823 A CN 114237823A CN 202111554910 A CN202111554910 A CN 202111554910A CN 114237823 A CN114237823 A CN 114237823A
- Authority
- CN
- China
- Prior art keywords
- message
- queue
- exception handling
- consumer
- delivery
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 48
- 238000003860 storage Methods 0.000 title claims abstract description 16
- 238000012545 processing Methods 0.000 claims abstract description 45
- 238000004590 computer program Methods 0.000 claims description 17
- 230000002159 abnormal effect Effects 0.000 claims description 14
- 238000001514 detection method Methods 0.000 claims description 4
- 238000000605 extraction Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 description 12
- 230000000903 blocking effect Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000006835 compression Effects 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000005520 cutting process Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000007958 sleep Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45579—I/O management, e.g. providing access to device drivers or storage
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses an exception handling method and device for a message queue, computer equipment and a storage medium, which are applied to the field of data processing. The method provided by the invention comprises the following steps: receiving a delivery message of a message producer, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name, acquiring the identification information of the message producer from the delivery message and acquiring the maximum retry number from annotation configuration of the message consumer if the failure of the consumption of the delivery message by any message consumer is detected, generating an exception handling queue through a section-oriented programming mechanism based on the identification information of the message producer, the consumer queue name, the maximum retry number and the message content, and performing exception handling on the delivery message by adopting the exception handling queue.
Description
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an apparatus for processing an exception of a message queue, a computer device, and a storage medium.
Background
The message queue Middleware (MQ) is an important component in the distributed system, mainly solves the problems of application decoupling, asynchronous messages, traffic cutting and the like, realizes a high-performance, high-availability, scalable and final consistency architecture, and is widely used in the distributed system. In service development, because of various exceptions (possibly, the exception of the service engineering itself, the memory exception of the JVM, or the virtual machine where the system is located is down, etc.), at present, the problem is mainly solved by message retry, where message retry refers to configuration of message retry for an MQ consumer by using a retry mechanism of an MQ, and configuring retry times and retry interval time, and the MQ retry mechanism performs message retry after capturing the exception.
The inventor finds that, in the process of implementing the present invention, the existing manner can solve the exception of the current MQ to a certain extent, but the configuration manner is effective for all consumption queues of the MQ consumers, cannot be configured for a single queue, and when the message consumption fails to retry, the current consumption thread sleeps to the retry time, and blocks other message consumption, so that the exception handling efficiency is low.
Disclosure of Invention
The invention provides a method and a device for processing the exception of a message queue, computer equipment and a storage medium, which are used for improving the exception processing efficiency of the message queue.
A message queue exception handling method comprises the following steps:
receiving a delivery message of a message producer, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name;
if it is detected that any message consumer fails to consume the delivery message, acquiring identification information of the message producer from the delivery message, and acquiring maximum retry times from annotation configuration of the message consumer;
generating an exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content;
and performing exception processing on the delivery message by adopting the exception processing queue.
Optionally, the identification information of the message producer and the name of the consumer queue are located at the message header of the delivery message.
Optionally, the generating an exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the consumer queue name, the maximum retry number, and the message content includes:
extracting exception handling logic based on a section-oriented programming mechanism;
and generating an exception handling queue comprising identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content based on the exception handling logic, wherein the exception handling queue comprises a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
Optionally, the performing exception processing on the message by using the exception handling queue includes:
initializing the current retry number to 0;
after each retry, increasing the current retry number by 1;
comparing the current retry number with the maximum retry number;
if the current retry number is less than or equal to the maximum retry number, delay processing is carried out on the delivery message by adopting the delay queue;
and if the current retry times are greater than the maximum retry times, performing exception handling on the delivery message by adopting the custom queue.
Optionally, if the current retry number is less than or equal to the maximum retry number, performing delay processing on the delivery message by using the delay queue includes:
acquiring a delivery message source;
if the delivery message source is the re-delivery of the consumer consumption failure, the message content is forwarded to a delay queue corresponding to the consumer queue name, and the current retry number is added by 1;
if the delivery message source is the delay queue, the current retry times, the maximum retry times and the consumer queue name are put into a message header and are assembled with the message content to obtain an updated delivery message, and the updated delivery message is put into the message consumer queue again for waiting processing.
Optionally, if the current retry number is greater than the maximum retry number, performing exception handling on the delivery message by using the custom queue includes:
and recording the retry record, generating abnormal information and storing the abnormal information in a database.
An exception handling apparatus for a message queue, comprising:
the system comprises a message receiving module, a message sending module and a message receiving module, wherein the message receiving module is used for receiving a delivery message of a message producer, and the delivery message comprises message content, identification information of the message producer and a consumer queue name;
a failure detection module, configured to, if it is detected that any message consumer fails to consume the delivery message, obtain identification information of the message producer from the delivery message, and obtain a maximum retry number from an annotation configuration of the message consumer;
a queue generating module, configured to generate an exception handling queue through a facet-oriented programming mechanism based on identification information of the message producer, the name of the consumer queue, the maximum retry number, and the message content;
and the exception handling module is used for carrying out exception handling on the delivery message by adopting the exception handling queue.
Optionally, the queue generating module includes:
the logic extraction unit is used for extracting the exception handling logic based on a section-oriented programming mechanism;
a queue generating unit, configured to generate, based on the exception handling logic, an exception handling queue including identification information of the identifier of the message producer, the name of the consumer queue, the maximum retry number, and the message content, where the exception handling queue includes a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
Optionally, the exception handling module includes:
a current retry number initialization unit configured to initialize the current retry number to 0;
a current retry number update unit for increasing the current retry number by 1 after performing a retry each time;
a number comparison unit for comparing the current retry number with the maximum retry number;
the delay processing unit is used for performing delay processing on the delivery message by adopting the delay queue if the current retry time is less than or equal to the maximum retry time;
and the exception handling unit is used for carrying out exception handling on the delivery message by adopting the custom queue if the current retry number is greater than the maximum retry number.
Optionally, the delay processing unit includes:
a source determining subunit, configured to obtain a source of the delivery message;
the first processing subunit is configured to, if the delivery message source is the consumer consumption failure and the delivery is resumed, forward the message content to a delay queue corresponding to the consumer queue name, and add 1 to the current retry number;
and the second processing subunit is configured to, if the source of the delivery message is the delay queue, put the current retry number, the maximum retry number, and the consumer queue name into a message header, assemble the message header with the message content to obtain an updated delivery message, and put the updated delivery message into the message consumer queue again for waiting for processing.
Optionally, the exception handling unit includes:
and the third processing subunit is used for recording the retry record, generating abnormal information and storing the abnormal information in a database.
A computer device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the steps of the above message queue exception handling method when executing said computer program.
A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the above-mentioned message queue exception handling method.
The invention provides an exception handling method, a device, a computer device and a storage medium of a message queue, which receive a delivery message of a message producer, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name, if the failure of any message consumer to consume the delivery message is detected, the identification information of the message producer is obtained from the delivery message, the maximum retry frequency is obtained from annotation configuration of the message consumer, an exception handling queue is generated by a section-oriented programming mechanism based on the identification information of the message producer, the consumer queue name, the maximum retry frequency and the message content, the delivery message is subjected to exception handling by the exception handling queue, the exception handling queue is customized by adding the identification information of the message producer and the consumer queue name in the delivery message, the message is ensured to be processed in time, abnormal processing written by each queue consumer independently is avoided, repeated codes are more and distributed in different subsystems, and low efficiency caused by incapability of unified processing is avoided, so that the abnormal processing efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a diagram of an application environment of a method for exception handling of a message queue according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for exception handling for a message queue according to one embodiment of the present invention;
FIG. 3 is a diagram illustrating an exception handling apparatus for a message queue according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The exception handling method for the message queue provided by the application can be applied to the application environment shown in fig. 1, wherein the terminal device communicates with the server through the network. The terminal device may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server may be implemented as a stand-alone server or as a server cluster consisting of a plurality of servers. The system framework 100 may include terminal devices, networks, and servers. The network serves as a medium for providing a communication link between the terminal device and the server. The network may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use a terminal device to interact with a server over a network to receive or send messages or the like.
The terminal devices 101, 102, 103 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, motion Picture experts compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, motion Picture experts compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that, the exception handling method for the message queue provided by the embodiment of the present invention is executed by the server, and accordingly, the exception handling apparatus for the message queue is disposed in the server.
It should be understood that the number of the terminal devices, the networks, and the servers in fig. 1 is only illustrative, and any number of the terminal devices, the networks, and the servers may be provided according to implementation requirements, and the terminal devices in the embodiment of the present invention may specifically correspond to an application system in actual production.
In an embodiment, as shown in fig. 2, a method for exception handling of a message queue is provided, which is described by taking the method as an example applied to the server in fig. 1, and includes the following steps S201 to S204.
S201: receiving a delivery message of a message producer, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name.
In particular, the producer-consumer model is to solve the problem of strong coupling between producer and consumer by one container. The producer and the consumer do not directly communicate with each other but communicate through the blocking queue, so that the producer does not wait for the consumer to process the data after producing the data, the data is directly thrown to the blocking queue, the consumer does not find the data required by the producer but directly takes the data from the blocking queue, and the blocking queue is equivalent to a buffer area, thereby balancing the processing capacities of the producer and the consumer.
Preferably, the identification information of the message producer and the consumer queue name are located at the message header of the delivery message.
In this embodiment, when the message producer delivers the message to the MQ, the following parameters are added to the message header: and the identification information of the message producer and the name of the consumer queue are obtained, so that the message carries the identification information of the producer and the name of the consumer queue when being delivered to the MQ.
The identification information is information for characterizing the identity of the message producer, and may specifically be an ID of the producer system.
Wherein the consumer queue name is used to direct delivery of a message to a corresponding consumer queue.
It should be understood that, there are multiple producers and multiple consumers in the MQ queue, and in this embodiment, producer identification information is added to a message, so that the message sources can be effectively distinguished, and a new queue is further customized to perform exception handling, without waiting for each message in the delay queue to be processed in sequence, thereby avoiding congestion caused by exception.
S202: and if the situation that any message consumer fails to consume the delivery message is detected, acquiring the identification information of the message producer from the delivery message, and acquiring the maximum retry number from the annotation configuration of the message consumer.
The maximum retry number may be set according to actual requirements, and is not limited herein.
In this embodiment, the maximum number of retries is configured in the message consumer note.
Note is added to the message consumers, and the maximum retry times allowed by the consumers are configured in the note, so that each queue consumer can customize the retry times of the queue consumer according to actual requirements, and the process of individually setting threads for each consumer distributed in different subsystems by using repeated codes is not needed, thereby being beneficial to unified processing and improving efficiency.
S203: and generating an exception handling queue through a section-oriented programming mechanism based on the identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content.
Specifically, the abnormal processing is performed on the consumer through a Spring-oriented section programming mechanism (Aop mechanism), and in the embodiment, the section-oriented programming mechanism mainly extracts the logic of the abnormal processing performed on the consumer and performs unified coding, so that the repeated coding is prevented from being used by all consumers.
The method is a technology for realizing unified maintenance of program functions by a precompilation mode and a dynamic proxy during running in a tangent plane Programming (AOP) Oriented technology. The AOP is a continuation of the OOP, is a hot spot in software development, is also an important content in a Spring framework, and is a derivative paradigm of functional programming. By utilizing the AOP, all parts of the business logic can be isolated, so that the coupling degree between all parts of the business logic is reduced, the reusability of a program is improved, and the development efficiency is improved.
Optionally, generating the exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the name of the consumer queue, the maximum number of retries, and the message content includes:
extracting exception handling logic based on a section-oriented programming mechanism;
and generating an exception handling queue comprising identification information of the message producer, a consumer queue name, the maximum retry number and message content based on the exception handling logic, wherein the exception handling queue comprises a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
S204: and performing exception processing on the delivery message by adopting an exception processing queue.
Further, in step S204, performing exception processing on the message by using the exception handling queue includes:
initializing the current retry number to 0;
after each retry, increasing the current retry number by 1;
comparing the current retry times with the maximum retry times;
if the current retry times are less than or equal to the maximum retry times, delay processing is carried out on the delivery message by adopting a delay queue;
and if the current retry times are larger than the maximum retry times, performing exception handling on the delivery message by adopting a custom queue.
Preferably, if the current retry number is less than or equal to the maximum retry number, the delaying the delivery message by using the delay queue includes:
acquiring a delivery message source;
if the delivery message source is the re-delivery of the consumer consumption failure, the message content is forwarded to a delay queue corresponding to the consumer queue name, and the current retry number is added by 1;
if the delivery message source is a delay queue, the current retry times, the maximum retry times and the consumer queue name are put into a message header and are assembled with the message content to obtain an updated delivery message, and the updated delivery message is put into the message consumer queue again for waiting processing.
Preferably, if the current retry number is greater than the maximum retry number, the performing exception handling on the delivery message by using the custom queue includes:
and recording the retry record, generating abnormal information and storing the abnormal information in a database.
In the embodiment, a delivery message of a message producer is received, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name, if it is detected that any message consumer fails to consume the delivery message, the identification information of the message producer is obtained from the delivery message, the maximum retry number is obtained from annotation configuration of the message consumer, an exception handling queue is generated through a section-oriented programming mechanism based on the identification information of the message producer, the consumer queue name, the maximum retry number and the message content, the delivery message is subjected to exception handling by adopting the exception handling queue, the identification information of the message producer and the consumer queue name are added into the delivery message, a user-defined exception handling queue is realized, the message is ensured to be handled in time, and the exception handling of each queue consumer is avoided, the repeated codes are more and distributed in different subsystems, so that the efficiency caused by the incapability of unified processing is low, and the exception handling efficiency is favorably improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In an embodiment, an exception handling apparatus for a message queue is provided, where the exception handling apparatus for the message queue corresponds to the exception handling method for the message queue in the foregoing embodiment one to one. As shown in fig. 3, the exception handling apparatus for the message queue includes a message receiving module 31, a failure detection module 32, a queue generating module 33, and an exception handling module 34, which are described in detail as follows:
a message receiving module 31, configured to receive a delivery message of a message producer, where the delivery message includes a message content, identification information of the message producer, and a consumer queue name;
a failure detection module 32, configured to, if it is detected that any message consumer fails to consume the delivery message, obtain identification information of the message producer from the delivery message, and obtain the maximum retry number from the annotation configuration of the message consumer;
a queue generating module 33, configured to generate an exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the name of the consumer queue, the maximum retry number, and the message content;
and the exception handling module 34 is used for performing exception handling on the delivery message by adopting the exception handling queue.
Optionally, the queue generating module 33 includes:
the logic extraction unit is used for extracting the exception handling logic based on a section-oriented programming mechanism;
and the queue generating unit is used for generating an exception processing queue containing identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content based on the exception processing logic, wherein the exception processing queue comprises a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
Optionally, the exception handling module 34 includes:
a current retry number initialization unit configured to initialize the current retry number to 0;
a current retry number update unit for increasing the current retry number by 1 after performing a retry each time;
a number comparison unit for comparing the current retry number with the maximum retry number;
the delay processing unit is used for delaying the delivery message by adopting the delay queue if the current retry number is less than or equal to the maximum retry number;
and the exception handling unit is used for carrying out exception handling on the delivery message by adopting the custom queue if the current retry number is greater than the maximum retry number.
Optionally, the delay processing unit includes:
the source determining subunit is used for acquiring a delivery message source;
the first processing subunit is used for forwarding the message content to a delay queue corresponding to the queue name of the consumer if the delivery message source is the re-delivery of the consumer consumption failure, and adding 1 to the current retry number;
and the second processing subunit is used for putting the current retry times, the maximum retry times and the consumer queue name into a message header if the delivery message source is the delay queue, assembling the message header with the message content to obtain an updated delivery message, and putting the updated delivery message into the message consumer queue again for waiting for processing.
Optionally, the exception handling unit includes:
and the third processing subunit is used for recording the retry record, generating abnormal information and storing the abnormal information in the database.
Wherein the meaning of "first" and "second" in the above modules/units is only to distinguish different modules/units, and is not used to define which module/unit has higher priority or other defining meaning. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to such process, method, article, or apparatus, and such that a division of modules presented in this application is merely a logical division and may be implemented in a practical application in a further manner.
The specific definition of the exception handling apparatus for the message queue may refer to the above definition of the exception handling method for the message queue, and is not described herein again. The modules in the exception handling apparatus of the message queue described above may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data involved in the exception handling method of the message queue. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of exception handling for a message queue.
In one embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the processor implements the steps of the exception handling method for the message queue in the above embodiments, such as the steps S201 to S204 shown in fig. 2 and other extensions of the method and extensions of related steps. Alternatively, the processor, when executing the computer program, implements the functions of the modules/units of the exception handling apparatus of the message queue in the above-described embodiment, for example, the functions of the modules 31 to 34 shown in fig. 3. To avoid repetition, further description is omitted here.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like which is the control center for the computer device and which connects the various parts of the overall computer device using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc.
The memory may be integrated in the processor or may be provided separately from the processor.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the steps of the method for exception handling of a message queue in the above-described embodiments, such as the steps S201 to S204 shown in fig. 2 and extensions of other extensions and related steps of the method. Alternatively, the computer program, when executed by the processor, implements the functions of the modules/units of the exception handling apparatus of the message queue in the above-described embodiment, for example, the functions of the modules 31 to 34 shown in fig. 3. To avoid repetition, further description is omitted here.
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 hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
Claims (10)
1. A method for exception handling for a message queue, the method comprising:
receiving a delivery message of a message producer, wherein the delivery message comprises message content, identification information of the message producer and a consumer queue name;
if it is detected that any message consumer fails to consume the delivery message, acquiring identification information of the message producer from the delivery message, and acquiring maximum retry times from annotation configuration of the message consumer;
generating an exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content;
and performing exception processing on the delivery message by adopting the exception processing queue.
2. The method of claim 1, wherein the identification information of the message producer and the name of the consumer queue are located at a message header of the delivery message.
3. The method for exception handling of message queue according to claim 1 or 2, wherein the generating an exception handling queue through a facet-oriented programming mechanism based on the identification information of the message producer, the consumer queue name, the maximum number of retries and the message content comprises:
extracting exception handling logic based on a section-oriented programming mechanism;
and generating an exception handling queue comprising identification information of the message producer, the name of the consumer queue, the maximum retry number and the message content based on the exception handling logic, wherein the exception handling queue comprises a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
4. The method of message queue exception handling according to claim 3, wherein said exception handling of the message using the exception handling queue comprises:
initializing the current retry number to 0;
after each retry, increasing the current retry number by 1;
comparing the current retry number with the maximum retry number;
if the current retry number is less than or equal to the maximum retry number, delay processing is carried out on the delivery message by adopting the delay queue;
and if the current retry times are greater than the maximum retry times, performing exception handling on the delivery message by adopting the custom queue.
5. The method as claimed in claim 4, wherein the delaying the posted message with the delay queue if the current retry number is less than or equal to the maximum retry number comprises:
acquiring a delivery message source;
if the delivery message source is the re-delivery of the consumer consumption failure, the message content is forwarded to a delay queue corresponding to the consumer queue name, and the current retry number is added by 1;
if the delivery message source is the delay queue, the current retry times, the maximum retry times and the consumer queue name are put into a message header and are assembled with the message content to obtain an updated delivery message, and the updated delivery message is put into the message consumer queue again for waiting processing.
6. The method as claimed in claim 4, wherein the exception handling of the delivered message using the custom queue if the current retry number is greater than the maximum retry number comprises:
and recording the retry record, generating abnormal information and storing the abnormal information in a database.
7. An exception handling apparatus for a message queue, the apparatus comprising:
the system comprises a message receiving module, a message sending module and a message receiving module, wherein the message receiving module is used for receiving a delivery message of a message producer, and the delivery message comprises message content, identification information of the message producer and a consumer queue name;
a failure detection module, configured to, if it is detected that any message consumer fails to consume the delivery message, obtain identification information of the message producer from the delivery message, and obtain a maximum retry number from an annotation configuration of the message consumer;
a queue generating module, configured to generate an exception handling queue through a facet-oriented programming mechanism based on identification information of the message producer, the name of the consumer queue, the maximum retry number, and the message content;
and the exception handling module is used for carrying out exception handling on the delivery message by adopting the exception handling queue.
8. The message queue exception handling method of claim 7, wherein the queue generating module comprises:
the logic extraction unit is used for extracting the exception handling logic based on a section-oriented programming mechanism;
a queue generating unit, configured to generate, based on the exception handling logic, an exception handling queue including identification information of the identifier of the message producer, the name of the consumer queue, the maximum retry number, and the message content, where the exception handling queue includes a delay queue and an exception queue, the delay queue is a deadlock queue, and the exception queue is a custom queue.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method of exception handling of a message queue according to any of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of a method for exception handling of a message queue according to one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111554910.0A CN114237823A (en) | 2021-12-17 | 2021-12-17 | Message queue exception handling method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111554910.0A CN114237823A (en) | 2021-12-17 | 2021-12-17 | Message queue exception handling method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114237823A true CN114237823A (en) | 2022-03-25 |
Family
ID=80758482
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111554910.0A Pending CN114237823A (en) | 2021-12-17 | 2021-12-17 | Message queue exception handling method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114237823A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115328680A (en) * | 2022-09-28 | 2022-11-11 | 天津卓朗昆仑云软件技术有限公司 | Message queue consumption abnormity assisting method and device and electronic equipment |
CN115866017A (en) * | 2023-02-27 | 2023-03-28 | 天翼云科技有限公司 | Message processing method, message processing device, communication equipment and storage medium |
CN116155849A (en) * | 2022-12-28 | 2023-05-23 | 中国联合网络通信集团有限公司 | Message delivery method and device, electronic equipment and storage medium |
CN117319320A (en) * | 2023-11-29 | 2023-12-29 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080059975A1 (en) * | 2006-08-14 | 2008-03-06 | Gioberti Stefano P | Message processing |
CN107656825A (en) * | 2017-09-01 | 2018-02-02 | 上海艾融软件股份有限公司 | Message treatment method, apparatus and system |
US20180375783A1 (en) * | 2017-06-27 | 2018-12-27 | Atlassian Pty Ltd | Retry handling in messaging queues |
CN112953810A (en) * | 2019-12-10 | 2021-06-11 | 北京沃东天骏信息技术有限公司 | Network request processing method and device |
CN113448757A (en) * | 2021-08-30 | 2021-09-28 | 阿里云计算有限公司 | Message processing method, device, equipment, storage medium and system |
-
2021
- 2021-12-17 CN CN202111554910.0A patent/CN114237823A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080059975A1 (en) * | 2006-08-14 | 2008-03-06 | Gioberti Stefano P | Message processing |
US20180375783A1 (en) * | 2017-06-27 | 2018-12-27 | Atlassian Pty Ltd | Retry handling in messaging queues |
CN107656825A (en) * | 2017-09-01 | 2018-02-02 | 上海艾融软件股份有限公司 | Message treatment method, apparatus and system |
CN112953810A (en) * | 2019-12-10 | 2021-06-11 | 北京沃东天骏信息技术有限公司 | Network request processing method and device |
CN113448757A (en) * | 2021-08-30 | 2021-09-28 | 阿里云计算有限公司 | Message processing method, device, equipment, storage medium and system |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115328680A (en) * | 2022-09-28 | 2022-11-11 | 天津卓朗昆仑云软件技术有限公司 | Message queue consumption abnormity assisting method and device and electronic equipment |
CN115328680B (en) * | 2022-09-28 | 2023-01-31 | 天津卓朗昆仑云软件技术有限公司 | Auxiliary method and device for message queue consumption abnormity and electronic equipment |
CN116155849A (en) * | 2022-12-28 | 2023-05-23 | 中国联合网络通信集团有限公司 | Message delivery method and device, electronic equipment and storage medium |
CN116155849B (en) * | 2022-12-28 | 2024-07-26 | 中国联合网络通信集团有限公司 | Message delivery method and device, electronic equipment and storage medium |
CN115866017A (en) * | 2023-02-27 | 2023-03-28 | 天翼云科技有限公司 | Message processing method, message processing device, communication equipment and storage medium |
CN115866017B (en) * | 2023-02-27 | 2023-06-23 | 天翼云科技有限公司 | Message processing method, device, communication equipment and storage medium |
CN117319320A (en) * | 2023-11-29 | 2023-12-29 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
CN117319320B (en) * | 2023-11-29 | 2024-02-13 | 佛山众陶联供应链服务有限公司 | Retry method and system for message consumption failure of message queue |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114237823A (en) | Message queue exception handling method and device, computer equipment and storage medium | |
US10554604B1 (en) | Low-load message queue scaling using ephemeral logical message topics | |
EP2948846B1 (en) | Resource calling for hybrid applications | |
US9128893B2 (en) | Remote direct memory access socket aggregation | |
AU2019256257B2 (en) | Processor core scheduling method and apparatus, terminal, and storage medium | |
CN112671760A (en) | Socket-based client cross-platform network communication method and related equipment thereof | |
CN112559476B (en) | Log storage method for improving performance of target system and related equipment thereof | |
CN110413822B (en) | Offline image structured analysis method, device and system and storage medium | |
CN109144487B (en) | Method, device, computer equipment and storage medium for developing business of parts | |
CN111858727B (en) | Multi-data source data export system and method based on template configuration | |
CN110879742A (en) | Method and device for asynchronously creating internal snapshot of virtual machine and storage medium | |
CN110209344B (en) | Method, device and computer readable storage medium for migrating object storage | |
CN112650804A (en) | Big data access method, device, system and storage medium | |
CN116541185A (en) | Data interaction method and device, electronic equipment and storage medium | |
US10572166B1 (en) | Firmware download for a solid state storage card | |
CN114090083B (en) | Visual component configuration method, device, equipment and storage medium | |
CN115437551A (en) | Data cloning method, device, storage medium and computer program product | |
CN113626222A (en) | Message processing method and device, computer equipment and storage medium | |
CN113779122A (en) | Method and apparatus for exporting data | |
CN112269941A (en) | Business real-time pushing method and system, electronic equipment and storage medium | |
US11500710B1 (en) | Stand-alone exception handler module | |
CN117560414A (en) | Micro-service calling method, system, computer equipment and storage medium | |
CN115378938A (en) | Network resource scheduling method, gateway equipment, edge and cloud data center server | |
CN115840768A (en) | Data processing method, device, equipment and storage medium | |
CN116881366A (en) | System for data synchronization |
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 |