CN109739660B - Abnormal message processing method and device - Google Patents

Abnormal message processing method and device Download PDF

Info

Publication number
CN109739660B
CN109739660B CN201811584453.8A CN201811584453A CN109739660B CN 109739660 B CN109739660 B CN 109739660B CN 201811584453 A CN201811584453 A CN 201811584453A CN 109739660 B CN109739660 B CN 109739660B
Authority
CN
China
Prior art keywords
message
queue
exception
abnormal
target
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.)
Active
Application number
CN201811584453.8A
Other languages
Chinese (zh)
Other versions
CN109739660A (en
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.)
New H3C Technologies Co Ltd Hefei Branch
Original Assignee
New H3C Technologies Co Ltd Hefei Branch
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 New H3C Technologies Co Ltd Hefei Branch filed Critical New H3C Technologies Co Ltd Hefei Branch
Priority to CN201811584453.8A priority Critical patent/CN109739660B/en
Publication of CN109739660A publication Critical patent/CN109739660A/en
Application granted granted Critical
Publication of CN109739660B publication Critical patent/CN109739660B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention relates to the technical field of information processing, and provides an abnormal message processing method and device, wherein the method comprises the following steps: when a basic message queue added by a message to be distributed is full, acquiring a current processing message in the basic message queue; determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first zone bits; and adding the current processing message into the target exception queue. When the message processing in the message queue head is abnormal, the invention adds the abnormal queue and puts the abnormal message into the abnormal queue to avoid blocking the distribution of the message behind the message queue.

Description

Abnormal message processing method and device
Technical Field
The invention relates to the technical field of information processing, in particular to an abnormal message processing method and device.
Background
When a management node manages a plurality of network nodes, a large amount of management messages are generally required to be distributed to each network node, in the prior art, efficient message distribution is generally realized by adopting a static message queue based on a target address hashing algorithm, the static message queue maintains a fixed number of message queues, a message distribution end firstly determines the serial number of the message queue through hash operation on the address of a message receiving end, and then the message to be distributed is placed into the message queue with the corresponding serial number to be processed.
Due to the adoption of the hash algorithm, the message to be distributed can quickly enter the message queue to wait for processing, so that the purpose of efficiently distributing the message is achieved, but the message processing of the head message in the message queue is abnormal, and the distribution of the message behind the head message in the message queue is influenced.
Disclosure of Invention
In view of this, the present invention provides an exception message processing method and apparatus, when the message processing in the message queue head is abnormal, an exception queue is added, and the message with abnormal processing is placed in the exception queue to avoid blocking the distribution of the message behind the head message in the message queue.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, the present invention provides an abnormal message processing method, which is applied to a message distribution end, where the message distribution end stores at least one basic message queue in advance, the basic message queue corresponds to a first flag bit, and the first flag bit is used to characterize the number of abnormal queues corresponding to the basic message queue. The method specifically comprises the following steps:
when a basic message queue added by a message to be distributed is full, a message distribution end acquires a current processing message in the basic message queue;
according to the first zone bit, a message distribution end determines a target abnormal queue from the abnormal queues corresponding to the basic message queues;
the message distribution end adds the current processing message into the target exception queue.
With reference to the first aspect, in a first possible implementation manner, the message distribution end prestores the total number of the abnormal queues corresponding to the basic message queue;
the process of determining the target abnormal queue by the message distribution end from the abnormal queue corresponding to the basic message queue according to the first zone bit specifically comprises the following steps:
if the first flag bit is 0, when the first flag bit is consistent with the total number of the abnormal queues, the message distribution end creates a new message queue and takes the message queue as a target abnormal queue.
With reference to the first aspect, in a second possible implementation manner, the message distribution terminal includes at least one exception queue;
the process of determining the target abnormal queue by the message distribution end from the abnormal queue corresponding to the basic message queue according to the first zone bit specifically comprises the following steps:
if the first flag bit is 0, when the first flag bit is inconsistent with the total number of the abnormal queues, the message distribution end determines an idle queue from at least one abnormal queue, and takes the idle queue as a target abnormal queue.
With reference to the first aspect, in a third possible implementation manner, the currently processed message includes a destination IP address, the message forwarding end includes at least one exception queue, each exception queue corresponds to a second flag bit, and the second flag bit is used to represent a key value corresponding to the exception queue;
the process of determining the target abnormal queue by the message distribution end from the abnormal queue corresponding to the basic message queue according to the first zone bit specifically comprises the following steps:
the message distribution end carries out Hash operation on the target IP address to obtain a key value corresponding to the target IP address;
if the first flag bit is not 0, when the key value corresponding to the destination IP address is consistent with the second flag bit, the message forwarding end determines the abnormal queue corresponding to the second flag bit as a target abnormal queue.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner, the method further includes:
when the key value corresponding to the target IP address is inconsistent with the second zone bit, the message distribution end judges whether the total number of the first zone bit is consistent with the total number of the at least one abnormal queue;
and when the first flag bit is consistent with the total number of the at least one abnormal queue, the message distribution terminal establishes a new message queue and takes the message queue as a target abnormal queue.
With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner, the method further includes:
and when the first flag bit is inconsistent with the total number of the at least one abnormal queue, the message distribution end determines an idle queue from the at least one abnormal queue and takes the idle queue as a target abnormal queue.
With reference to the third possible implementation manner of the first aspect, in a sixth possible implementation manner, the process of adding, by the message distribution end, the currently processed message to the target exception queue specifically is:
and the message transmitting end adds the target message with the same key value as the currently processed message in the basic message queue and the currently processed message into the target abnormal queue.
With reference to the third possible implementation manner of the first aspect, in a seventh possible implementation manner, a process in which the message distribution end adds the currently processed message to the target exception queue specifically is:
and if the message to be distributed and the current processing message have the same key value, the message distribution end adds the message to be distributed and the current processing message into the target exception queue.
With reference to the first, second, fourth, and fifth possible implementation manners of the first aspect, in an eighth possible implementation manner, after the message forwarding end adds the currently processed message to the target exception queue, the method further includes:
and the message distribution end increases the number of the abnormal queues which are represented by the first zone bits and correspond to the basic message queues.
In a second aspect, the present invention further provides an exception message handling apparatus, which is applied to a message forwarding end, where the message forwarding end stores at least one basic message queue in advance, each basic message queue corresponds to a first flag bit, and the first flag bit is used to characterize the number of exception queues corresponding to the basic message queue. The device comprises an acquisition module, a determination module and an adding module;
the acquisition module is used for acquiring the current processing message in the basic message queue when the basic message queue added by the message to be distributed is full;
the determining module is used for determining a target abnormal queue from the abnormal queue corresponding to the basic message queue according to the first zone bit;
and the adding module is used for adding the current processing message into the target exception queue.
With reference to the second aspect, in a first possible implementation manner, the apparatus prestores a total number of exception queues corresponding to a base message queue;
the determining module is specifically configured to, if the first flag bit is 0, create a message queue when the first flag bit is consistent with the total number of the abnormal queues, and use the message queue as a target abnormal queue.
With reference to the second aspect, in a second possible implementation manner, the apparatus includes at least one exception queue;
the determining module is specifically configured to determine, if the first flag bit is 0, one idle queue from the at least one exception queue when the first flag bit is inconsistent with the total number of the exception queues, and use the idle queue as a target exception queue.
With reference to the second aspect, in a third possible implementation manner, the current processing message acquired by the acquisition module includes a destination IP address, the apparatus includes at least one exception queue, each exception queue corresponds to a second flag bit, and the second flag bit is used to represent a key value corresponding to the exception queue;
the determining module is specifically used for carrying out Hash operation on the destination IP address to obtain a key value corresponding to the destination IP address;
and if the first flag bit is not 0, determining the abnormal queue corresponding to the second flag bit as the target abnormal queue when the key value corresponding to the destination IP address is consistent with the second flag bit.
With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner, the determining module is further specifically configured to:
when the key value corresponding to the target IP address is inconsistent with the second zone bit, judging whether the total number of the first zone bit and the total number of the at least one abnormal queue are consistent;
and when the first flag bit is consistent with the total number of the at least one abnormal queue, establishing a message queue, and taking the message queue as a target abnormal queue.
With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner, the determining module is further specifically configured to:
and when the first flag bit is inconsistent with the total number of the at least one exception queue, determining a free queue from the at least one exception queue, and taking the free queue as a target exception queue.
With reference to the third possible implementation manner of the second aspect, in a sixth possible implementation manner, the adding module is specifically configured to add the target message having the same key value as the currently processed message in the basic message queue and the currently processed message to the target exception queue.
With reference to the third possible implementation manner of the second aspect, in a seventh possible implementation manner, the adding module is specifically configured to add the message to be distributed and the currently processed message into the target exception queue if the message to be distributed and the currently processed message have the same key value.
With reference to the first, second, fourth, and fifth possible implementation manners of the second aspect, in an eighth possible implementation manner, the apparatus further includes:
and the increasing module is used for increasing the number of the abnormal queues which are represented by the first zone bits and correspond to the basic message queues.
Compared with the prior art, the method and the device for processing the abnormal message provided by the embodiment of the invention have the advantages that firstly, a message distributing end generates the message to be distributed based on a user request, and when a basic message queue added with the message to be distributed is full, the current processing message in the basic message queue is acquired; then, according to a first zone bit corresponding to the basic message queue, determining a target abnormal queue from the abnormal queue corresponding to the basic message queue; and finally, adding the processed message into a target abnormal queue to eliminate the influence of the processed message on the distribution of other messages in the same basic message queue. Compared with the prior art, when the message processing of the head message in the basic message queue is abnormal, the abnormal queue is added, and the message with abnormal processing is put into the abnormal queue to avoid blocking the distribution of the message behind the head message in the message queue.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
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 embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic diagram illustrating an application scenario of an exception message processing method according to an embodiment of the present invention.
Fig. 2 is a block diagram illustrating a message distribution end provided by an embodiment of the present invention.
Fig. 3 is a flowchart illustrating an exception message handling method according to an embodiment of the present invention.
Fig. 4 is a flowchart illustrating sub-steps of step S102 shown in fig. 3.
Fig. 5 is a flowchart illustrating sub-steps of step S103 shown in fig. 3.
Fig. 6 is a diagram illustrating an example of a processing procedure for currently processing a message according to an embodiment of the present invention.
Fig. 7 is a diagram illustrating another example of a process for currently processing a message according to an embodiment of the present invention.
Fig. 8 is a diagram illustrating another example of a process for currently processing a message according to an embodiment of the present invention.
Fig. 9 is a flowchart of a process when the basic message queue is not full according to an embodiment of the present invention.
Fig. 10 is a block diagram illustrating an exception message handling apparatus according to an embodiment of the present invention.
Icon: 10-a message distribution end; 101-a memory; 102-a communication interface; 103-a processor; 104-a bus; 20-a message receiving end; 200-exception message handling means; 201-an acquisition module; 202-a determination module; 203-adding module; 204-increment module.
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 only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Referring to fig. 1, fig. 1 is a schematic view illustrating an application scenario of an abnormal message processing method according to an embodiment of the present invention, in fig. 1, a message distribution end 10 is in communication connection with a plurality of message receiving ends 20, the message distribution end 10 generates a message to be distributed based on a user request, when the message to be distributed is added to a basic message queue, if the basic message queue is full, it is considered that the message receiving end 20 corresponding to a currently processed message in the basic message queue is abnormal, the currently processed message is an abnormal message, a target abnormal queue is determined from the abnormal queue corresponding to the basic message queue according to a first flag bit corresponding to the basic message queue, and the currently processed message is added to the target abnormal queue, so as to avoid blocking distribution of messages behind the currently processed message in the same message queue.
Referring to fig. 2, fig. 2 is a block diagram illustrating a message distributor 10 according to an embodiment of the present invention. The message distribution terminal 10 may be, but is not limited to, a host, a virtual machine, a physical server, a virtual machine on a physical server, or the like, which can provide the same function as the server or the virtual machine. The operating system of the message distributor 10 may be, but is not limited to, a Windows system, a Linux system, etc. The message originator 10 comprises a memory 101, a communication interface 102, a processor 103 and a bus 104, the memory 101, the communication interface 102 and the processor 103 being connected via the bus 104, the processor 103 being configured to execute an executable module, such as a computer program, stored in the memory 101.
The Memory 101 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The message originator 10 is communicatively coupled to at least one other message recipient 20 via at least one communication interface 102 (which may be wired or wireless).
The bus 104 may be an ISA bus, PCI bus, EISA bus, or the like. Only one bi-directional arrow is shown in fig. 2, but this does not indicate only one bus or one type of bus.
The memory 101 is used to store a program, such as the exception message processing apparatus 200 shown in fig. 10. The exception message handling apparatus 200 includes at least one software function module which may be stored in the memory 101 in the form of software or firmware (firmware) or fixed in an Operating System (OS) of the message distributor 10. After receiving the execution instruction, the processor 103 executes the program to implement the exception message handling method disclosed in the above embodiment of the present invention.
First embodiment
Referring to fig. 3, fig. 3 is a flowchart illustrating an exception message handling method according to an embodiment of the present invention. The method comprises the following steps:
step S101, when the basic message queue added by the message to be distributed is full, the current processing message in the basic message queue is obtained.
In the embodiment of the present invention, the message to be distributed may be generated by the message distribution end 10 based on a user request, or may be a message forwarded by the message distribution end 10 receiving another device, or may be generated based on a request sent by another device. The basic message queue may include messages of a plurality of message receivers 20, each message including message content and a destination IP address, where the destination IP address is an IP address of the message receiver 20 corresponding to the message.
Normally, the message to be distributed is added to the tail of the basic message queue, and the message distribution end 10 starts processing from the message at the head of the basic message queue when processing the message in the basic message queue, which of course may not be performed in this order, and is not limited herein. The currently processed message is a message which exists in the basic message queue, is processed and is not processed yet, and once the message processing is completed, the currently processed message is removed from the basic message queue and the next message is processed.
The basic message queues all have a preset queue length, that is, the maximum number of messages that can be added in the basic message queues, and when the number of messages added in the basic message queues reaches the preset queue length, the basic message queues are considered to be full, at this time, the message distribution terminal 10 determines that the message receiving terminal 20 that is processing the messages is abnormal, so that the messages that are being processed cannot be distributed in time, and finally, the subsequent messages to be processed are continuously added in the basic message queues, so that the basic message queues are full.
In the embodiment of the present invention, when the number of the message receiving terminals 20 is small, there may be only one basic message queue, and the messages of all the message receiving terminals 20 are managed by the same basic message queue, and when the number of the message receiving terminals 20 is large, in order to implement the concurrent distribution of the message distribution, a plurality of basic message queues may be used, and each basic message queue manages the messages of a plurality of message receiving terminals 20.
As an embodiment, the plurality of base message queues may be organized in an array, i.e. one base message queue for each element in the array. The method for determining the basic message queue to which the message to be distributed belongs according to the message to be distributed can be as follows: and carrying out Hash operation on the target IP address in the message to be distributed to obtain a corresponding key value, and obtaining the index sequence number of the array of the basic message queue of the message to be distributed by taking the modulus of the key value in the message to be distributed and the total number of the basic message queue.
For example, the number of the basic message queues is 4, the corresponding arrays are Slot [0] [0], Slot [1] [0], Slot [2] [0], and Slot [3] [0], and if the key value in the message to be distributed is 12, the index number of the corresponding array is: 12% 5 ═ 2, then the message to be dispatched should be placed in the base message queue Slot [2] [0 ]. Similarly, if the key value in the message to be distributed is 15, the index number of the corresponding array is: 15% 5 ═ 0, then the message to be dispatched should be placed in the base message queue Slot [0] [0 ].
In the embodiment of the invention, the basic message queue is managed in an array mode, and the corresponding basic message queue can be quickly and directly determined by taking a module according to the key value in the message, so that the message processing speed is improved.
And step S102, determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first zone bit.
In the embodiment of the invention, each basic message queue corresponds to a first flag bit, and the first flag bit is used for representing the number of the abnormal queues corresponding to the basic message queues. In the embodiment of the present invention, the meaning of an exception queue may be extended as follows: the exception queue is characterized as corresponding to an exception message receiver 20.
The abnormal message receiving end 20 is the message receiving end 20 that is abnormal when receiving the message, and after the message distribution end 10 sends the message to the message receiving end 20, the message distribution end 10 does not receive the corresponding feedback information within the preset time, and at this time, the message distribution end 10 determines that the corresponding message receiving end 20 is abnormal. The message receiver 20 is abnormal, including but not limited to, a power failure of the message receiver 20, a failure of the message receiver 20, or an abnormality of the network of the message receiver 20.
The first flag bit is initialized to 0 during initialization, when a basic message queue added by a message to be distributed is full, it is determined that a message receiving end 20 corresponding to a currently processed message in the basic message queue is abnormal, at this time, the currently processed message is added into a target abnormal queue, and the first flag bit is incremented.
The target exception queue is a queue specially storing exception messages, and the exception messages are messages which are to be sent to the message receiving end 20 but have an exception. It will be appreciated that each target exception queue corresponds to an exception message receiver 20.
For example, when the current first flag is 0, and at time T1, the currently processed message corresponds to the # 1 message receiver 20. When the 1# message receiving terminal 20 is judged to be abnormal, adding the currently processed message at the time of T1 into the abnormal queue corresponding to the 1# message receiving terminal 20; while incrementing the first flag bit. At this time, the first flag bit is updated to 1.
At time T2, the currently processed message corresponds to the 2# message receiver 20. If the 2# message receiving terminal 20 is judged to be abnormal, adding the current processing message at the time of T2 into the abnormal queue corresponding to the 2# message receiving terminal 20; while incrementing the first flag bit. At this time, the first flag bit is updated to 2.
At time T3, the currently processed message corresponds to the 2# message receiver 20. Since the 2# message receiver 20 has already occurred with an exception, the currently processed message at the time T3 is added to the exception queue corresponding to the 2# message receiver 20. At this time, there is no new abnormal message receiver 20. Thus, the first flag bit is not incremented.
In the embodiment of the present invention, in order to determine the target exception queue, step S102 may further include the following sub-steps, please refer to fig. 4, and step S102 includes the following sub-steps:
in the sub-step S1021, it is determined whether the first flag bit is 0.
In the embodiment of the present invention, the first flag bit is 0, which means that the current corresponding basic message queue has no abnormal queue, i.e. no abnormality occurs in the message receiving end 20 corresponding to the basic message queue. When the first flag bit is 0, the sub-step S1022 is executed to determine whether the first flag bit is consistent with the total number of the abnormal queues corresponding to the basic message queue. When the first flag bit coincides with the total number of exception queues, sub-step S1023 is performed. When the first flag does not coincide with the total number of exception queues, sub-step S1024 is performed.
In the sub-step S1022, it is determined whether the first flag is consistent with the total number of the exception queues.
In the embodiment of the present invention, the states of the exception queue include an in-use state and an idle state, and the total number of the exception queue here is the total number of the exception queue in the two states.
And a sub-step S1023 of creating a message queue and using the message queue as a target exception queue.
In the embodiment of the present invention, the first flag is 0, and the total number of the exception queues is also 0, which means that no exception has occurred in the message receiving end 20 of the corresponding basic message queue, and no exception queue has been created. At this time, in order to add the currently processed message into the exception queue and to implement isolation of the exception message receiving end 20, a new message queue needs to be established, and the message queue is used as a target exception queue, and then the currently processed message is added into the target exception queue.
And a substep S1024, determining a free queue from the at least one exception queue, and using the free queue as a target exception queue.
In the embodiment of the present invention, when all the messages in the abnormal queue are processed, the abnormal queue becomes the idle queue, and the idle queue is not released, so that the message receiving end 20 can be directly used next time when an abnormality occurs, and at this time, the queue does not need to be created again, so that the message processing efficiency is improved.
When the abnormal queue becomes idle, the corresponding second flag bit is set to 0, so that whether the abnormal queue is an idle queue can be determined by whether the second flag bit of the abnormal queue is 0, when the second flag bit is 0, the corresponding abnormal queue is considered to be an idle queue, and when a plurality of idle queues are available, one idle queue can be selected from the plurality of idle queues as a target abnormal queue according to a preset rule. For example, the first found idle queue may be used as a target exception queue, or the last found idle queue may be used as a target exception queue, and a rule is preset specifically, which is not limited in the embodiment of the present invention.
In the embodiment of the present invention, each abnormal queue corresponds to a second flag, where the second flag is used to represent a key value corresponding to the corresponding abnormal queue, and the destination IP addresses in the messages in the abnormal queues are the same, that is, each abnormal queue corresponds to one abnormal message receiving end 20, so that the key value of the abnormal queue is obtained by performing hash operation on the IP address of the message receiving end 20 corresponding to the abnormal queue.
If the first flag bit is not 0, it indicates that there is a corresponding abnormal queue in the basic message queue, at this time, sub-step S1025 needs to be executed, that is, a key value corresponding to the destination IP address is obtained according to the destination IP address in the current processed message, then sub-step S1026 is executed, that is, it is determined whether the key value of the current processed message is consistent with the second flag bit of the abnormal queue, if so, the abnormal queue consistent with the key value of the current processed message is taken as the target abnormal queue; if not, further judging whether the total number of the first flag bit is consistent with the total number of the at least one abnormal queue, if the key value of the current processing message is consistent with the second flag bit, executing a substep S1027, and finally determining the target abnormal queue.
And a substep S1025 of obtaining a corresponding key value according to the destination IP address.
And a substep S1026 of determining whether the key value corresponding to the destination IP address is consistent with the second flag bit.
In the sub-step S1027, the exception queue corresponding to the second flag bit is determined as a target exception queue.
In the embodiment of the present invention, the key value corresponding to the destination IP address is consistent with the second flag bit, which means that there is already an exception queue corresponding to the message receiving end 20 that currently processes the message, and therefore, the currently processed message may be directly added to the corresponding exception queue.
In the embodiment of the present invention, the exception queue corresponding to the base message queue and characterized by the first flag bit is a used exception queue, that is, a non-empty exception queue, and the total number of the exception queue corresponding to the base message queue includes the used exception queue and an idle exception queue.
For example, the first flag bit is 2, the total number of the exception queues is 2, the corresponding second flag bits are 123 and 124, respectively, the 1# exception queue and the 2# exception queue, and after the message in the 1# exception queue is processed, the second flag bit corresponding to the 1# exception queue is 0, the first flag bit is decremented to 1, and the total number of the exception queues is still 2.
In the embodiment of the present invention, when the key value corresponding to the destination IP address is inconsistent with the second flag, the sub-step S1022 is executed, and it is determined whether the total number of the first flag and the at least one exception queue is consistent, and when the total number of the first flag and the at least one exception queue is consistent, the sub-step S1023 is executed, that is, a new message queue is created, and the message queue is used as the target exception queue. When the first flag bit is inconsistent with the total number of the at least one exception queue, performing a sub-step S1024, namely determining a free queue from the at least one exception queue, and using the free queue as a target exception queue.
And step S103, adding the current processing message into a target exception queue.
In the embodiment of the invention, the current processing message at the head of the basic queue is added into the target abnormal queue, so that the message after the current processing message is processed in time, and the message distribution efficiency is improved.
However, when there is a destination message having the same abnormal message receiving end 20 as the currently processed message in the basic message queue, or a message to be added has the same message receiving end 20 as the currently processed message, in order to avoid that the destination message or the message to be added affects the processing of other messages in the basic message queue, the efficiency of message distribution is further improved, and the purpose of completely shielding the abnormal message receiving end 20 is achieved, please refer to fig. 5, the embodiment of the present invention further includes substep S1031 and substep S1032.
In the embodiment of the present invention, in order to move the destination message in the basic message queue, which has the same key value as the currently processed message, from the basic message queue to the target exception queue, the embodiment of the present invention further includes a sub step S1031.
And a substep S1031, adding the message with the same key value as the currently processed message in the basic message queue and the currently processed message into the target abnormal queue.
In the embodiment of the present invention, if the message to be added and the currently processed message have the same key value, in order to add the message to be distributed to the target exception queue, the embodiment of the present invention further includes a sub step S1032.
And a substep S1032, if the message to be distributed and the current processing message have the same key value, adding the message to be distributed and the current processing message into the target exception queue.
In the embodiment of the present invention, when the key value of the basic message queue corresponding to each currently used exception queue is not 0, which is the key value of the destination IP address of the currently processed message, the first flag bit needs to be incremented, so the embodiment of the present invention further includes step S104.
And step S104, increasing the number of the abnormal queues corresponding to the basic message queues and characterized by the first zone bits.
In the embodiment of the present invention, there are two cases of incrementing the first flag bit: (1) the target abnormal queue is a newly added queue; (2) the target exception queue is determined from the free queue.
For simplicity of description, each message is directly described in fig. 6, 7 and 8 below as including a key value and message content, where the key value is obtained by performing a hash operation according to a destination IP address in the message, and in an actual scenario, the destination IP address is included in the message instead of the corresponding key value, and the descriptions in fig. 6, 7 and 8 are only exemplary and simplified descriptions.
Referring to fig. 6, fig. 6 shows an exemplary processing procedure of a currently processed message according to an embodiment of the present invention, before processing the message, a key Value of a message to be distributed is 20, Value1 is a message content of the message, and 3 messages exist in a basic message queue Slot [0] [0], where the key Value of the currently processed message is 20, the message content is Value4, the length of the basic message queue is 3, and the total number of exception queues is 0, that is, there is no exception queue.
When the message to be distributed is added into the basic message queue Slot [0] [0], the basic message queue is full, the first flag bit is 0, and is consistent with the total number of the exception queues, the exception queue Slot [0] [1] is created, the Slot [0] [1] is used as a target exception queue, then the current processing message in the basic message queue Slot [0] [0] is added into the target exception queue Slot [0] [1], the first flag bit is incremented to 1, the second flag bit is set as the key value of the current processing message 20, and the key value of the message to be distributed is also 20, so the message to be distributed is also added into the target exception queue Slot [0] [1 ].
Referring to fig. 7, fig. 7 is a diagram illustrating another example of a processing procedure of currently processing a message according to an embodiment of the present invention, before processing the message, a key Value of a message to be distributed is 40, Value1 is a message content of the message, 3 messages exist in a base message queue Slot [0] [0], where a key Value of the currently processed message is 30, a message content is Value4, a length of the base message queue is 3, a total number of exception queues is 1, one exception queue Slot [0] [1] exists, and a second flag bit of the exception queue Slot is 20, where the exception queue includes 2 messages.
When the message to be distributed is added into the basic message queue Slot [0] [0], the basic message queue is full, the first flag bit is not 0, the key value 30 of the current processing message is inconsistent with the second flag bit 20 of the exception queue Slot [0] [1], a queue Slot [0] [2] is created, the Slot [0] [2] is used as a target exception queue, then the current processing message in the basic message queue Slot [0] [0] is added into the target exception queue Slot [0] [2], the first flag bit is increased to 2, the second flag bit of the target exception queue Slot [0] [2] is set as the key value 30 of the current processing message, and the key value of the message to be distributed is 40 and inconsistent with the key value of the current processing message, so the message to be distributed is added into the basic message queue Slot [0] [0 ].
Referring to fig. 8, fig. 8 shows another exemplary processing procedure of currently processing a message according to an embodiment of the present invention, before processing the message, a key Value of the message to be distributed is 40, Value1 is its message content, and there are 3 messages in a base message queue Slot [0] [0], where the key Value of the currently processed message is 30, the message content is Value4, the length of the base message queue is 3, the total number of exception queues is 1, there is one exception queue Slot [0] [1], and a second flag bit of the exception queue is 0, that is, the exception queue is a free queue.
When the message to be distributed is added into the basic message queue Slot [0] [0], the basic message queue is full, the first flag bit is 0, the first flag bit 0 is inconsistent with the total number 1 of the abnormal queues, a free queue Slot [0] [1] is found from the abnormal queues to serve as a target abnormal queue, then the current processing message in the basic message queue Slot [0] [0] is added into the target abnormal queue Slot [0] [1], the first flag bit is incremented to 1, the second flag bit of the target abnormal queue Slot [0] [1] is set to be the key value 30 of the current processing message, and the key value of the message to be distributed is 40 and inconsistent with the key value of the current processing message, so the message to be distributed is added into the basic message queue Slot [0] [0 ].
It should be noted that, when the abnormal message receiving end 20 returns from the abnormality to the normal state, the message in the corresponding abnormal queue is quickly processed, and after the message in the abnormal queue is processed, the second flag bit of the abnormal queue needs to be set to 0, and the corresponding first flag bit needs to be decremented.
It should be further noted that, when the message to be distributed is added to the basic message queue, if the basic message queue is not full, the processing process refers to fig. 9, and fig. 9 is a processing flow chart provided in the embodiment of the present invention when the basic message queue is not full, first, it is determined whether the first flag bit is 0, if the first flag bit is 0, the message to be distributed is directly added to the basic message queue, if the first flag bit is not 0, it is determined whether the key value of the message to be distributed is consistent with the second flag bit of the abnormal queue, if the key value of the message to be distributed is consistent with the second flag bit of the abnormal queue, the message to be distributed is added to the abnormal queue that is consistent with the key value of the message to be distributed, and if the key value of the message to be distributed is not consistent with the second flag bit of the abnormal queue, the message to be distributed is directly added to the basic message queue.
In the embodiment of the present invention, when the message receiving end 20 is abnormal, the abnormal queue is added, and the message of the abnormal message receiving end 20 is placed in the abnormal queue to shield the abnormal message receiving end 20, compared with the prior art, the present invention has the following beneficial effects:
firstly, when the current processing message in the head of the basic message queue is abnormal, the message with abnormal processing is put into an abnormal queue, so as to avoid blocking the distribution of other messages behind the basic message queue.
Secondly, the messages to be distributed having the same message receiving end 20 as the exception handling messages and the target messages in the basic message queue having the same message receiving end 20 as the exception handling messages are screened and placed in the exception queue, so that the abnormal message receiving end 20 is timely and comprehensively shielded, and the influence of the abnormal message receiving end 20 on the message distribution of the normal message receiving end 20 in other basic message queues is effectively controlled.
Secondly, the judgment processing process in the abnormal message processing flow is optimized and the efficiency of processing the abnormal message is improved by adding the first zone bit to each basic message queue and adding the second zone bit to each abnormal queue.
Second embodiment
Referring to fig. 10, fig. 10 is a block diagram illustrating an exception message handling apparatus 200 according to an embodiment of the present invention. The exception message processing apparatus 200 is applied to the message distribution terminal 10, and includes an obtaining module 201; a determination module 202; a join module 203; an increment module 204.
The obtaining module 201 is configured to obtain a current processing message in a basic message queue when the basic message queue added by a message to be distributed is full.
In this embodiment of the present invention, the obtaining module 201 is configured to execute step S101.
The determining module 202 is configured to determine a target exception queue from the exception queue corresponding to the basic message queue according to the first flag.
In an embodiment of the present invention, the determining module 202 is configured to perform step S102 and sub-steps S1021-S1027 thereof.
And the adding module 203 is used for adding the current processing message into the target exception queue.
In the embodiment of the present invention, the adding module 203 is configured to execute step S103 and sub-steps S1031 to S1032 thereof.
And an incrementing module 204, configured to increment the number of the exception queues corresponding to the base message queue and characterized by the first flag bit.
In this embodiment of the present invention, the increment module 204 is configured to execute step S104.
Further, the device prestores the total number of abnormal queues corresponding to the basic message queues;
the determining module 202 is specifically configured to, if the first flag bit is 0, create a message queue when the first flag bit is consistent with the total number of the abnormal queues, and use the message queue as a target abnormal queue.
Further, the apparatus includes at least one exception queue;
the determining module 202 is specifically configured to, if the first flag bit is 0, determine, when the first flag bit is inconsistent with the total number of the exception queues, one free queue from the at least one exception queue, and use the free queue as a target exception queue.
Further, the current processing message acquired by the acquiring module 201 includes a destination IP address, the apparatus includes at least one exception queue, each exception queue corresponds to a second flag bit, and the second flag bit is used for representing a key value corresponding to the exception queue;
the determining module 202 is specifically configured to perform a hash operation on the destination IP address to obtain a key value corresponding to the destination IP address;
and if the first flag bit is not 0, determining the abnormal queue corresponding to the second flag bit as the target abnormal queue when the key value corresponding to the destination IP address is consistent with the second flag bit.
Further, the determining module 202 is specifically configured to, when the key value corresponding to the target IP address is inconsistent with the second flag bit, determine whether the total number of the first flag bit and the total number of the at least one abnormal queue are consistent; and when the first flag bit is consistent with the total number of the at least one abnormal queue, establishing a message queue, and taking the message queue as a target abnormal queue.
Further, the determining module 202 is specifically configured to determine, when the first flag bit is inconsistent with the total number of the at least one exception queue, a free queue from the at least one exception queue, and use the free queue as a target exception queue.
Further, the adding module 203 is specifically configured to add the target message in the basic message queue, which has the same key value as the currently processed message, and the currently processed message into the target exception queue.
Further, the adding module 203 is specifically configured to add the message to be distributed and the currently processed message into the target exception queue if the message to be distributed and the currently processed message have the same key value.
In summary, the method and apparatus for processing exception messages provided by the present invention include: when a basic message queue added by a message to be distributed is full, acquiring a current processing message in the basic message queue; determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first zone bits; and adding the current processing message into the target exception queue. When the message processing in the message queue head is abnormal, the invention adds the abnormal queue and puts the abnormal message into the abnormal queue to avoid blocking the distribution of the message behind the message queue.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s).
It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.

Claims (10)

1. An exception message processing method applied to a message distribution end, wherein the message distribution end stores at least one basic message queue in advance, each basic message queue corresponds to a first flag bit, and the first flag bit is used for representing the number of exception queues corresponding to the basic message queues, and the method comprises the following steps:
when the basic message queue added by the message to be distributed is full, acquiring the current processing message in the basic message queue;
determining a target abnormal queue from the abnormal queue corresponding to the basic message queue according to the first zone bit;
and adding the current processing message into the target exception queue.
2. The exception message handling method of claim 1, wherein said message distribution side stores in advance a total number of exception queues corresponding to said base message queue;
determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first flag bit, specifically including:
and if the first zone bit is 0, establishing a message queue when the total number of the first zone bit is consistent with that of the abnormal queues, and taking the message queue as a target abnormal queue.
3. The exception message handling method of claim 1, wherein said message originator comprises at least one exception queue;
determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first flag bit, specifically including:
if the first flag bit is 0, determining an idle queue from the at least one exception queue when the total number of the first flag bit is inconsistent with the total number of the exception queues, and taking the idle queue as a target exception queue.
4. The exception message handling method according to claim 1, wherein said currently processed message includes a destination IP address, said message distribution end includes at least one exception queue, each of said exception queues corresponds to a second flag bit, said second flag bit is used for characterizing a key value corresponding to said exception queue;
determining a target abnormal queue from the abnormal queues corresponding to the basic message queues according to the first flag bit, specifically including:
carrying out Hash operation on the target IP address to obtain a key value corresponding to the target IP address;
and if the first flag bit is not 0, determining the abnormal queue corresponding to the second flag bit as a target abnormal queue when the key value corresponding to the destination IP address is consistent with the second flag bit.
5. The method for processing exception messages according to claim 4, wherein the determining a target exception queue from the exception queues corresponding to the base message queue according to the first flag bit further comprises:
when the key value corresponding to the destination IP address is inconsistent with the second flag bit, judging whether the total number of the first flag bit and the total number of the at least one abnormal queue are consistent;
and when the first flag bit is consistent with the total number of at least one abnormal queue, establishing a message queue, and taking the message queue as a target abnormal queue.
6. The method for processing exception messages according to claim 5, wherein the determining a target exception queue from the exception queues corresponding to the base message queue according to the first flag bit further comprises:
when the first flag bit is inconsistent with the total number of the at least one exception queue, determining a free queue from the at least one exception queue, and taking the free queue as a target exception queue.
7. The exception message handling method of claim 4, wherein said adding said currently processed message to said target exception queue comprises:
and adding the target message with the same key value as the currently processed message in the basic message queue and the currently processed message into the target abnormal queue.
8. The exception message handling method of claim 4, wherein said adding said currently processed message to said target exception queue comprises:
and if the message to be distributed and the current processing message have the same key value, adding the message to be distributed and the current processing message into the target exception queue.
9. The exception message handling method of one of claims 2, 3, 5, 6, wherein after said adding said currently processed message to said target exception queue, said method further comprises:
and increasing the number of the abnormal queues corresponding to the basic message queues and characterized by the first zone bits.
10. An exception message handling apparatus, for use in a message distribution terminal, where the message distribution terminal stores at least one basic message queue in advance, and each basic message queue corresponds to a first flag bit, where the first flag bit is used to characterize the number of exception queues corresponding to the basic message queue, and the apparatus includes:
the acquisition module is used for acquiring the current processing message in the basic message queue when the basic message queue added by the message to be distributed is full;
the determining module is used for determining a target abnormal queue from the abnormal queue corresponding to the basic message queue according to the first zone bit;
and the adding module is used for adding the current processing message into the target exception queue.
CN201811584453.8A 2018-12-24 2018-12-24 Abnormal message processing method and device Active CN109739660B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811584453.8A CN109739660B (en) 2018-12-24 2018-12-24 Abnormal message processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811584453.8A CN109739660B (en) 2018-12-24 2018-12-24 Abnormal message processing method and device

Publications (2)

Publication Number Publication Date
CN109739660A CN109739660A (en) 2019-05-10
CN109739660B true CN109739660B (en) 2020-10-16

Family

ID=66359676

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811584453.8A Active CN109739660B (en) 2018-12-24 2018-12-24 Abnormal message processing method and device

Country Status (1)

Country Link
CN (1) CN109739660B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112887196B (en) * 2021-01-20 2023-03-24 远景智能国际私人投资有限公司 Message sending method, system, device, equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101719079A (en) * 2009-12-17 2010-06-02 中国电力科学研究院 Method and device for processing tasks
CN102663086A (en) * 2012-04-09 2012-09-12 华中科技大学 Method for retrieving data block indexes
CN103838513A (en) * 2012-11-22 2014-06-04 深圳市中兴微电子技术有限公司 Method and device for dynamic control over memory reading and writing
CN106028098A (en) * 2016-05-26 2016-10-12 努比亚技术有限公司 Video recording method, device, and terminal
CN107483635A (en) * 2017-09-22 2017-12-15 浪潮软件集团有限公司 Service request processing method, processing system and message middleware

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7827444B2 (en) * 2007-09-28 2010-11-02 Intel Corporation Application crash resist method and apparatus

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101719079A (en) * 2009-12-17 2010-06-02 中国电力科学研究院 Method and device for processing tasks
CN102663086A (en) * 2012-04-09 2012-09-12 华中科技大学 Method for retrieving data block indexes
CN103838513A (en) * 2012-11-22 2014-06-04 深圳市中兴微电子技术有限公司 Method and device for dynamic control over memory reading and writing
CN106028098A (en) * 2016-05-26 2016-10-12 努比亚技术有限公司 Video recording method, device, and terminal
CN107483635A (en) * 2017-09-22 2017-12-15 浪潮软件集团有限公司 Service request processing method, processing system and message middleware

Also Published As

Publication number Publication date
CN109739660A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
WO2019232071A1 (en) Aggregation of scalable network flow events
US10225145B2 (en) Method and device for updating client
CN111555963B (en) Message pushing method and device, electronic equipment and storage medium
US9654433B2 (en) Selective message republishing to subscriber subsets in a publish-subscribe model
JP6359111B2 (en) Method and apparatus for processing data packets based on parallel protocol stack instances
CN112333289A (en) Reverse proxy access method, device, electronic equipment and storage medium
CN109739660B (en) Abnormal message processing method and device
US9122546B1 (en) Rapid processing of event notifications
CN114064668A (en) Method, electronic device and computer program product for storage management
US9154519B1 (en) System and method for antivirus checking of objects from a plurality of virtual machines
US9652310B1 (en) Method and apparatus for using consistent-hashing to ensure proper sequencing of message processing in a scale-out environment
CN110061917B (en) Interface group creating method and device, network equipment and storage medium
CN109086128B (en) Task scheduling method and device
CN113132241B (en) ACL template dynamic configuration method and device
CN107210996B (en) Service chain management method and device
CN110830378A (en) Address table item updating method and switching equipment
CN114070801A (en) Message processing method, message transmission method, device and electronic equipment
CN110912797B (en) Method and device for forwarding broadcast message
CN110866066B (en) Service processing method and device
CN107086965B (en) ARP (Address resolution protocol) table entry generation method and device and switch
CN110837431A (en) Service control method, service control device, computer equipment and computer-readable storage medium
CN110768834A (en) Method, system, device and medium for notifying configuration upgrading result of virtual machine
CN109491948B (en) Data processing method and device for double ports of solid state disk
CN111355818B (en) Address resolution scheduling method and device and address resolution system
CN110071868B (en) Link aggregation method, device and network equipment

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
GR01 Patent grant
GR01 Patent grant