Disclosure of Invention
The application aims to provide a method, a device, electronic equipment and a storage medium for adjusting message priority, so that an emergency message can be responded in time, and the message processing efficiency is improved.
In a first aspect, the present application provides a method for adjusting message priority, including the steps of:
A1. acquiring a message and working information sent by a message main body;
A2. acquiring a preset priority of the message;
A3. acquiring a working state coefficient according to the working information;
A4. placing the message in a first message queue;
A5. calculating the priority value of the message according to the preset priority of the message and the working state coefficient by the first consumer of the first message queue;
A6. placing, by a first consumer of the first message queue, the message into a corresponding second topic type of a second message queue based on the priority value;
A7. and consuming the message by a second consumer of the corresponding second topic type.
According to the method for adjusting the message priority, the first consumer of the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, and the first consumer readjusts the priority value of the message according to the priority value, so that the situation that some messages sent by message main bodies during key operation need to be processed preferentially but cannot be processed in time is avoided, and therefore the urgent messages can be responded in time; the messages are put into the corresponding second theme type of the second message queue according to the priority values through the first consumer of the first message queue, the messages are consumed through the corresponding second consumer of the second theme type, for different second theme types, the messages in the second theme type are respectively consumed by different second consumers, the consumption processes of the messages in different second theme types are not influenced mutually, the messages with high priority values and the messages with low priority values are put into different second theme types, so that the processing process of the messages with low priority values cannot influence the processing process of the messages with high priority values, the processing process of the messages with high priority values cannot influence the processing process of the messages with low priority values, the urgent messages are ensured to be responded in time, and meanwhile, the waiting time of the non-urgent messages can be avoided, the efficiency of message processing is improved.
Preferably, step a2 includes:
determining a type of the message;
and acquiring the corresponding preset priority according to the type of the message.
Preferably, the working information includes location information and status information;
step a3 includes:
acquiring a first state coefficient according to the position information;
acquiring a second state coefficient according to the state information;
and calculating the working state coefficient according to the first state coefficient and the second state coefficient.
According to the method and the device, the current working state coefficient of the message body is obtained through comprehensive calculation according to the position and the state of the message body, the priority of the message is adjusted by utilizing the working state coefficient, the priority can be reasonably adjusted, and further the information needing to be processed preferentially can be responded in time.
Preferably, step a5 includes:
and calculating the product of the preset priority of the message and the working state coefficient by the first consumer of the first message queue to obtain the priority value.
The priority value is obtained by calculating the product of the preset priority of the message and the working state coefficient, and the priority of the message is adjusted according to the priority value.
Preferably, step a4 includes:
placing the message into a corresponding first theme type of the first message queue according to the preset priority;
step a5 includes:
calculating the priority value of the message according to the preset priority of the message and the working state coefficient by the first consumer of the corresponding first theme type;
step a6 includes:
placing, by the first consumer of the corresponding first topic type, the message into the corresponding second topic type of the second message queue according to the priority value.
The method comprises the steps of putting messages into corresponding first theme types of a first message queue according to preset priority, respectively consuming the messages in the first theme types by different first consumers for different first theme types, wherein the consumption processes of the messages in the different first theme types are not influenced by each other, and the messages with high preset priority and the messages with low preset priority are put into the different first theme types, so that the processing process of the messages with low preset priority cannot influence the processing process of the messages with high preset priority, and the processing process of the messages with high preset priority cannot influence the processing process of the messages with low preset priority, so that the messages with high preset priority can be processed in time, generally, the probability that the adjusted priority value of the messages with high preset priority is higher than the adjusted priority value of the messages with low preset priority is higher, therefore, the messages with different preset priorities are put into different first theme types for parallel processing, and the messages needing to be processed preferentially can be processed in time.
Preferably, the second message queue comprises a plurality of different second topic types, each of the second topic types corresponding to a different priority value range;
step a6 includes:
and the first consumer through the first message queue puts the message into the corresponding second theme type of the second message queue according to the range of the priority value.
Preferably, step a7 includes:
consuming the message by one of the second consumers of the corresponding second topic type.
In a second aspect, the present application provides an apparatus for adjusting message priority, comprising:
the first acquisition module is used for acquiring the message and the working information sent by the message main body;
the second acquisition module is used for acquiring the preset priority of the message;
the third acquisition module is used for acquiring a working state coefficient according to the working information;
a first processing module for placing said message in a first message queue;
the calculation module is used for calculating the priority value of the message according to the preset priority of the message and the working state coefficient through the first consumer of the first message queue;
a second processing module for placing, by the first consumer of the first message queue, the message into a corresponding second topic type of a second message queue according to the priority value;
and the execution module is used for consuming the message through the second consumer of the corresponding second theme type.
According to the device for adjusting the message priority, the first consumer of the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, and the first consumer readjusts the priority value of the message according to the priority value, so that the situation that some messages sent by message main bodies during key operation need to be processed preferentially but cannot be processed in time is avoided, and therefore the urgent messages can be responded in time; the messages are put into the corresponding second theme type of the second message queue according to the priority values through the first consumer of the first message queue, the messages are consumed through the corresponding second consumer of the second theme type, for different second theme types, the messages in the second theme type are consumed by different second consumers respectively, the consumption processes of the messages in different second theme types are not influenced mutually, the messages with high priority values and the messages with low priority values can be put into different second theme types, therefore, the processing process of the messages with low priority values can not influence the processing process of the messages with high priority values, the processing process of the messages with high priority values can not influence the processing process of the messages with low priority values, thereby ensuring that the urgent messages can be responded in time and avoiding the waiting time of non-urgent messages, the efficiency of message processing is improved.
In a third aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor executes the computer program to perform the steps of the method for adjusting message priority as described above.
In a fourth aspect, the present application provides a computer storage medium having stored thereon a computer program which, when executed by a processor, performs the steps in the method of adjusting message priority as described above.
Has the advantages that:
according to the method, the device, the electronic equipment and the storage medium for adjusting the message priority, the message and the working information sent by the message main body are obtained; acquiring a preset priority of the message; acquiring a working state coefficient according to the working information; placing the message in a first message queue; calculating the priority value of the message according to the preset priority of the message and the working state coefficient by the first consumer of the first message queue; placing, by a first consumer of the first message queue, the message into a corresponding second topic type of a second message queue based on the priority value; consuming the message by a second consumer of the corresponding second topic type; the urgent message is responded in time, and the message processing efficiency is improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
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 application, 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.
Since the priority of the message is preset in the control system, the message will not change normally, but in practical application, some message bodies cannot be processed in time when the message sent during the critical operation needs to be processed preferentially.
Referring to fig. 1, fig. 1 is a method for adjusting message priority according to the present application, where the method for adjusting message priority includes the steps of:
A1. acquiring a message and working information sent by a message main body;
A2. acquiring a preset priority of a message;
A3. acquiring a working state coefficient according to the working information;
A4. placing the message in a first message queue;
A5. calculating a priority value of the message according to the preset priority and the working state coefficient of the message by a first consumer of the first message queue;
A6. placing, by the first consumer of the first message queue, the message into the corresponding second topic type of the second message queue according to the priority value;
A7. the message is consumed by a second consumer of the corresponding second topic type.
According to the method for adjusting the message priority, the first consumer of the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, and the first consumer readjusts the priority value of the message according to the priority value, so that the situation that some messages sent by message main bodies during key operation need to be processed preferentially but cannot be processed in time is avoided, and therefore the urgent messages can be responded in time; the messages are put into the corresponding second theme type of the second message queue according to the priority values through the first consumer of the first message queue, the messages are consumed through the corresponding second consumer of the second theme type, for different second theme types, the messages in the second theme type are respectively consumed by different second consumers, the consumption processes of the messages in different second theme types are not influenced mutually, the messages with high priority values and the messages with low priority values are put into different second theme types, so that the processing process of the messages with low priority values cannot influence the processing process of the messages with high priority values, the processing process of the messages with high priority values cannot influence the processing process of the messages with low priority values, the urgent messages are ensured to be responded in time, and meanwhile, the waiting time of the non-urgent messages can be avoided, the efficiency of message processing is improved.
Specifically, the message body is a device for sending a message, and may be an automated device such as an AGV transport vehicle, a robot arm, or a robot.
Specifically, the preset priority may be set in advance for different messages according to the type of the message body and the type of the message itself, or only according to the type of the message itself, and the specific setting rule may be set according to actual needs, which is not limited herein. The preset priority may represent a processing level or an emergency degree of the message, and may be represented by an arabic number, a letter, or another symbol, in this embodiment, the preset priority is preferably represented by an arabic number, which is convenient for calculation, wherein the higher the preset priority is, the larger the corresponding arabic number is; for example, the preset priority of the alarm message of the mechanical arm is set to 10, while the priority of the mechanical arm activation message is set to 1, and the like, the preset priority of the specific message may set a corresponding priority value according to the urgency of the message, which is not limited thereto.
In practical application, the priority of the general message is preset, the message is processed according to the preset priority in the using process, but this does not take into account the environment in which the message body is located, when the message body is in a critical location or critical state, the message sent by the message body needs to be processed preferentially, which results in that the message needing to be processed preferentially is not processed in time, and therefore, in the present example, it is considered that the work information of the message body, such as the state information of the work, the location information and the like, and setting a corresponding working state coefficient according to the working state and the working position of the message main body, and further determining the priority value of the message sent by the message main body according to the preset priority level and the working state coefficient of the message, so that the emergency message sent in a key state is prevented from being processed in time.
Specifically, the messages are placed in a first message queue, a first consumer of the first message queue calculates the priority value of the messages according to the priority level and the working state coefficient of the messages, the first consumer readjusts the priority level of the messages according to the priority value, the messages are placed in a corresponding second theme type of a second message queue, and the second consumer of the corresponding second theme type consumes the messages, so that the messages with higher priority levels are responded in time.
It should be understood that the first Consumer and the second Consumer are both consumers of the message, are outlets of the message (see concumer in Kafka messaging system), and the first topic type and the second topic type are categories of published records or feed names (see topic in Kafka messaging system).
In some embodiments, step a2 includes:
determining the type of the message;
and acquiring the corresponding preset priority according to the type of the message.
Specifically, the type of the message may include a start message, an alarm message, a standby message, a shutdown message, or the like, and is not particularly limited thereto.
Specifically, corresponding type codes can be set for different types of messages in advance, and the message body includes the corresponding type codes in the message when sending the message, so that the type of the message can be determined by extracting the type codes.
In practical application, a preset priority look-up table can be formed according to the mapping relation between different types of codes and corresponding preset priorities, so that the step of acquiring the corresponding preset priorities according to the types comprises the following steps: and inquiring in a preset priority inquiry table according to the type code of the message to obtain the corresponding preset priority.
In other embodiments, a corresponding preset priority lookup table may be set for different message bodies according to identity information (e.g., ip information) of the different message bodies, and the step of obtaining the corresponding preset priority according to the type includes: and extracting a corresponding preset priority query table according to the identity information of the message body, and querying in the preset priority query table according to the type code of the message to obtain the corresponding preset priority.
In some embodiments, the operational information includes location information and status information;
step a3 includes:
acquiring a first state coefficient according to the position information;
acquiring a second state coefficient according to the state information;
and calculating the working state coefficient according to the first state coefficient and the second state coefficient.
In practical applications, the operation information may include position information and state information, or other information related to the operation, and is not particularly limited thereto, the position information may be position type information of a position where the message body is located, for example, a road surface with uneven pits, an uphill road section, a road intersection, a straight road section, and the like, corresponding first state coefficients may be allocated to different position types in advance, for example, the first state coefficient of the straight road section may be set to 1, the first state coefficient of the uphill road section may be set to 6, the first state coefficient of the road intersection may be set to 8, and the like, and may be set according to actual needs. The state information can be emergency state information or non-emergency state information, the emergency state and the non-emergency state can be divided according to actual needs, and a second state coefficient corresponding to the emergency state information can be set to be a numerical value larger than or equal to 1; and the second state coefficient corresponding to the non-emergency state information is set to a value greater than 0 and smaller than 1, which is not limited to this.
Specifically, if the first state coefficient is 8 and the second state coefficient is 2, the product may be calculated according to the first state coefficient and the second state coefficient to obtain the working state coefficient, that is, 8 × 2= 16; the operating state coefficient may also be obtained by calculating the sum of the first state coefficient and the second state coefficient, that is, 8+2=10, and in this embodiment, it is preferable to calculate the product according to the first state coefficient and the second state coefficient, so as to obtain the operating state coefficient, which is not limited to this.
In some embodiments, step a5 includes:
and calculating the product of the preset priority of the message and the working state coefficient by the first consumer of the first message queue to obtain a priority value.
Specifically, after the working state coefficient is obtained, the latest priority of the message is calculated comprehensively according to the preset priority of the message, the product or the sum of the preset priority and the working state coefficient may be adopted, the product is preferably adopted as the priority value in the embodiment, and the first consumer readjusts the priority of the message according to the size of the priority value, so that the message needing to be processed in priority is processed in time.
The messages can be sequentially placed into the first message queue for queuing according to the message sending time sequence, and the first consumer of the first message queue sequentially processes the messages according to the queuing sequence.
In some preferred embodiments, step a4 includes:
placing the messages into a corresponding first theme type of a first message queue according to a preset priority;
step a5 includes:
calculating a priority value of the message according to the preset priority and the working state coefficient of the message by the corresponding first consumer of the first theme type;
step a6 includes:
the messages are placed in the corresponding second topic type of the second message queue according to the priority values by the first consumer of the corresponding first topic type.
In practical application, the messages are put into the corresponding first theme types of the first message queue according to the preset priority, for different first theme types, the messages in the first theme types are respectively consumed by different first consumers, the consumption processes of the messages in the different first theme types are not influenced mutually, the messages with high preset priority and the messages with low preset priority are put into the different first theme types, so that the processing process of the messages with low preset priority does not influence the processing process of the messages with high preset priority, and the processing process of the messages with high preset priority does not influence the processing process of the messages with low preset priority, so that the messages with high preset priority can be processed in time, generally, the probability that the adjusted priority value of the messages with high preset priority is higher than the adjusted priority value of the messages with low preset priority is higher, therefore, the messages with different preset priorities are put into different first theme types for parallel processing, and the messages needing to be processed preferentially can be processed in time.
It should be understood that the message may be placed in the corresponding first topic type according to the urgency of the message, and the parallel processing may be performed, so that the urgent message and the non-urgent message are not affected by each other. Each first topic type corresponds to a different preset priority range, so that the step of placing the message into the corresponding first topic type of the first message queue according to the preset priority comprises the following steps: and placing the messages into the corresponding first theme type of the first message queue according to the range of the preset priority.
Preferably, in the first message queue, each first topic type is provided with a plurality of first consumers correspondingly, and the plurality of first consumers are used for processing a plurality of messages in the same first topic type in parallel, so as to improve the processing efficiency. Therefore, the step of calculating the priority value of the message according to the preset priority and the working state coefficient of the message by the first consumer of the corresponding first theme type comprises the following steps: and calculating the priority value of the message according to the preset priority and the working state coefficient of the message by one of the first consumers of the corresponding first theme type.
In some embodiments, the second message queue comprises a plurality of different second topic types, each second topic type corresponding to a different range of priority values;
step a6 includes:
the first consumer via the first message queue places the message in the corresponding second topic type in the second message queue based on the range of priority values.
Specifically, the second message queue includes a plurality of different second topic types, each second topic type corresponds to a different priority value range, for example, a first consumer places a message with a priority value range of 8-10 (excluding 8, including 10, which can be set according to actual needs, and is not limited here) in a first second topic type, and places a message with a priority value range of 6-8 (excluding 6, including 8, which can be set according to actual needs, and is not limited here) in a second topic type, so that messages with similar urgency degrees can be consumed by a second consumer in the same topic type, thereby improving the processing efficiency of the message.
It should be understood that, according to the specific range of the urgency degree of the message, the message is put into the corresponding second topic type for parallel processing, so that the urgent message and the non-urgent message are not affected by each other.
Preferably, in the second message queue, each second topic type is correspondingly provided with a plurality of second consumers, and the plurality of second consumers are used for processing a plurality of messages in the same second topic type in parallel, so as to improve the processing efficiency. Thus, step a7 includes:
the message is consumed by one of a plurality of second consumers of a corresponding second topic type.
Specifically, the message is consumed by one of the second consumers of the corresponding second topic type, and the step of dynamically calculating the priority value is added, so that the processing speed may be affected, and therefore, the second consumers are added to process a plurality of messages in the same second topic type in parallel, and the processing speed is further improved.
In view of the above, the method for adjusting the priority of the message provided by the present application obtains the message and the working information sent by the message body; acquiring a preset priority of a message; acquiring a working state coefficient according to the working information; placing the message in a first message queue; calculating a priority value of the message according to the preset priority and the working state coefficient of the message by a first consumer of the first message queue; placing, by the first consumer of the first message queue, the message into the corresponding second topic type of the second message queue according to the priority value; consuming the message by a second consumer of the corresponding second topic type; the urgent message is responded in time, and the message processing efficiency is improved.
Referring to fig. 2, the present application provides an apparatus for adjusting message priority, including:
the first acquisition module 1 is used for acquiring the message and the working information sent by the message main body;
the second obtainingmodule 2 is used for obtaining the preset priority of the message;
the third obtainingmodule 3 is used for obtaining the working state coefficient according to the working information;
a first processing module 4, for placing the message into a first message queue;
thecalculation module 5 is used for calculating the priority value of the message according to the preset priority and the working state coefficient of the message by the first consumer of the first message queue;
asecond processing module 6, configured to place, by the first consumer in the first message queue, the message into a corresponding second topic type in a second message queue according to the priority value;
and theexecution module 7 is used for consuming the message by the second consumer of the corresponding second theme type.
According to the device for adjusting the message priority, the first consumer of the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, and the first consumer readjusts the priority value of the message according to the priority value, so that the situation that some messages sent when key operation is carried out on message main bodies need to be processed preferentially but cannot be processed in time is avoided, and therefore the urgent message can be responded in time; the messages are put into the corresponding second theme type of the second message queue according to the priority values through the first consumer of the first message queue, the messages are consumed through the corresponding second consumer of the second theme type, for different second theme types, the messages in the second theme type are respectively consumed by different second consumers, the consumption processes of the messages in different second theme types are not influenced mutually, the messages with high priority values and the messages with low priority values are put into different second theme types, so that the processing process of the messages with low priority values cannot influence the processing process of the messages with high priority values, the processing process of the messages with high priority values cannot influence the processing process of the messages with low priority values, the urgent messages are ensured to be responded in time, and meanwhile, the waiting time of the non-urgent messages can be avoided, the efficiency of message processing is improved.
Specifically, the message body is a device for sending a message, and may be an automated device such as an AGV transport vehicle, a robot arm, or a robot.
Specifically, the preset priority may be set in advance for different messages according to the type of the message body and the type of the message itself, or only according to the type of the message itself, and the specific setting rule may be set according to actual needs, which is not limited herein. The preset priority may represent a processing level or an emergency degree of the message, and may be represented by an arabic number, a letter, or another symbol, in this embodiment, the preset priority is preferably represented by an arabic number, which is convenient for calculation, wherein the higher the preset priority is, the larger the corresponding arabic number is; for example, the preset priority of the alarm message of the mechanical arm is set to 10, while the priority of the mechanical arm activation message is set to 1, and the like, the preset priority of the specific message may set a corresponding priority value according to the urgency of the message, which is not limited thereto.
In practical application, the priority of the common message is preset, the message is processed according to the preset priority in the using process, but this does not take into account the environment in which the message body is located, when the message body is in a critical location or critical state, the message sent by the message body needs to be processed preferentially, which results in that the message needing to be processed preferentially is not processed in time, and therefore, in the present example, it is considered that the work information of the message body, such as the state information of the work, the location information and the like, and setting a corresponding working state coefficient according to the working state and the working position of the message main body, and further determining the priority value of the message to be sent according to the preset priority and the working state coefficient of the message to avoid that the emergency message sent in a key state is not processed in time.
Specifically, the messages are placed in a first message queue, a first consumer of the first message queue calculates the priority value of the messages according to the priority level and the working state coefficient of the messages, the first consumer readjusts the priority level of the messages according to the priority value, the messages are placed in a corresponding second theme type of a second message queue, and the second consumer of the corresponding second theme type consumes the messages, so that the messages with higher priority levels are responded in time.
It should be understood that the first Consumer and the second Consumer are both consumers of the message, are outlets of the message (see concumer in Kafka messaging system), and the first topic type and the second topic type are categories of published records or feed names (see topic in Kafka messaging system).
In some embodiments, the second obtainingmodule 2 specifically executes, when obtaining the preset priority of the message:
determining the type of the message;
and acquiring the corresponding preset priority according to the type of the message.
Specifically, the type of the message includes a start message, an alarm message, a standby message, a shutdown message, or the like, and is not particularly limited thereto.
Specifically, corresponding type codes can be set for different types of messages in advance, and when the message body sends the message, the corresponding type codes are contained in the message, so that the type of the message can be determined by extracting the type codes.
In practical application, a preset priority query table can be formed according to the mapping relationship between different types of codes and corresponding preset priorities, so that the second obtainingmodule 2 specifically executes the following steps when obtaining the corresponding preset priorities according to the types: and inquiring in a preset priority inquiry table according to the type code of the message to obtain the corresponding preset priority.
In other embodiments, a corresponding preset priority query table may be set for different message bodies according to identity information (e.g., ip information) of the different message bodies, so that the second obtainingmodule 2 specifically performs, when obtaining a corresponding preset priority according to the type: and extracting a corresponding preset priority query table according to the identity information of the message body, and querying in the preset priority query table according to the type code of the message to obtain the corresponding preset priority.
In some embodiments, the operational information includes location information and status information;
the third obtainingmodule 3 specifically executes the following steps when obtaining the working state coefficient according to the working information:
acquiring a first state coefficient according to the position information;
acquiring a second state coefficient according to the state information;
and calculating the working state coefficient according to the first state coefficient and the second state coefficient.
In practical applications, the operation information may include position information and state information, or other information related to the operation, and is not particularly limited thereto, the position information may be position type information of a position where the message body is located, for example, a road surface with uneven pits, an uphill road section, a road intersection, a straight road section, and the like, corresponding first state coefficients may be allocated to different position types in advance, for example, the first state coefficient of the straight road section may be set to 1, the first state coefficient of the uphill road section may be set to 6, the first state coefficient of the road intersection may be set to 8, and the like, and may be set according to actual needs. The state information can be emergency state information or non-emergency state information, the emergency state and the non-emergency state can be divided according to actual needs, and a second state coefficient corresponding to the emergency state information can be set to be a numerical value larger than or equal to 1; and the second state coefficient corresponding to the non-emergency state information is set to a value greater than 0 and smaller than 1, which is not limited to this.
Specifically, if the first state coefficient is 8 and the second state coefficient is 2, the product may be calculated according to the first state coefficient and the second state coefficient to obtain the working state coefficient, that is, 8 × 2= 16; the operating state coefficient may also be obtained by calculating the sum of the first state coefficient and the second state coefficient, that is, 8+2=10, and the embodiment preferably calculates the product of the first state coefficient and the second state coefficient to obtain the operating state coefficient, which is not limited to this.
In some embodiments, when the first consumer who passes through the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, the calculatingmodule 5 specifically performs:
and calculating the product of the preset priority of the message and the working state coefficient by the first consumer of the first message queue to obtain a priority value.
Specifically, after the working state coefficient is obtained, the latest priority of the message is calculated comprehensively according to the preset priority of the message, the product or the sum of the preset priority and the working state coefficient may be adopted, the product is preferably adopted as the priority value in the embodiment, and the first consumer readjusts the priority of the message according to the size of the priority value, so that the message needing to be processed in priority is processed in time.
The messages can be sequentially placed into the first message queue for queuing according to the message sending time sequence, and the first consumers of the first message queue sequentially process the messages according to the queuing sequence.
In some preferred embodiments, the first processing module 4 specifically performs, when placing a message into the first message queue:
placing the messages into a corresponding first theme type of a first message queue according to a preset priority;
when the first consumer who passes through the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, thecalculation module 5 specifically executes:
calculating a priority value of the message according to the preset priority and the working state coefficient of the message by the corresponding first consumer of the first theme type;
thesecond processing module 6 specifically executes, when the first consumer who has passed through the first message queue puts the message into the corresponding second topic type of the second message queue according to the priority value:
the messages are placed in the corresponding second topic type of the second message queue according to the priority values by the first consumer of the corresponding first topic type.
In practical application, the messages are put into the corresponding first theme types of the first message queue according to the preset priority, for different first theme types, the messages in the first theme types are respectively consumed by different first consumers, the consumption processes of the messages in the different first theme types are not influenced mutually, the messages with high preset priority and the messages with low preset priority are put into the different first theme types, so that the processing process of the messages with low preset priority does not influence the processing process of the messages with high preset priority, and the processing process of the messages with high preset priority does not influence the processing process of the messages with low preset priority, so that the messages with high preset priority can be processed in time, generally, the probability that the adjusted priority value of the messages with high preset priority is higher than the adjusted priority value of the messages with low preset priority is higher, therefore, the messages with different preset priorities are put into different first theme types for parallel processing, and the messages needing to be processed preferentially can be processed in time.
It should be understood that the message may be placed in the corresponding first topic type according to the urgency of the message, and the parallel processing may be performed, so that the urgent message and the non-urgent message are not affected by each other. Each first topic type corresponds to a different preset priority range, so that when the first processing module 4 puts the message into the corresponding first topic type of the first message queue according to the preset priority, the following specific steps are executed: and placing the messages into the corresponding first theme type of the first message queue according to the range of the preset priority.
Preferably, in the first message queue, each first topic type is provided with a plurality of first consumers correspondingly, and the plurality of first consumers are used for processing a plurality of messages in the same first topic type in parallel, so as to improve the processing efficiency. Therefore, when the calculatingmodule 5 calculates the priority value of the message according to the preset priority and the working state coefficient of the message by the first consumer of the corresponding first topic type, the following steps are specifically executed: and calculating the priority value of the message according to the preset priority and the working state coefficient of the message by one of the first consumers of the corresponding first theme type.
In some embodiments, the second message queue comprises a plurality of different second topic types, each second topic type corresponding to a different range of priority values;
thesecond processing module 6 specifically executes, when the first consumer who has passed through the first message queue puts the message into the corresponding second topic type of the second message queue according to the priority value:
the first consumer via the first message queue places the message in the corresponding second topic type in the second message queue based on the range of priority values.
Specifically, the second message queue includes a plurality of different second topic types, each second topic type corresponds to a different priority value range, for example, a first consumer places a message with a priority value range of 8-10 (excluding 8, including 10, which can be set according to actual needs, and is not limited here) in a first second topic type, and places a message with a priority value range of 6-8 (excluding 6, including 8, which can be set according to actual needs, and is not limited here) in a second topic type, so that messages with similar urgency degrees can be consumed by a second consumer in the same topic type, thereby improving the processing efficiency of the message.
It should be understood that, according to the specific range of the urgency degree of the message, the message is put into the corresponding second topic type for parallel processing, so that the urgent message and the non-urgent message are not affected.
Preferably, in the second message queue, each second topic type is correspondingly provided with a plurality of second consumers, and the plurality of second consumers are used for processing a plurality of messages in the same second topic type in parallel, so as to improve the processing efficiency. Thus, when consuming the message by the second consumer of the corresponding second topic type, theexecution module 7 specifically executes:
the message is consumed by one of a plurality of second consumers of a corresponding second topic type.
Specifically, the message is consumed by one of the second consumers of the corresponding second topic type, and the step of dynamically calculating the priority value is added, so that the processing speed may be affected, and therefore, the second consumers are added to process a plurality of messages in the same second topic type in parallel, and the processing speed is further improved.
According to the device for adjusting the message priority, the first consumer of the first message queue calculates the priority value of the message according to the preset priority and the working state coefficient of the message, and the first consumer readjusts the priority value of the message according to the priority value, so that the messages sent by some message main bodies during key operation are prevented from being preferentially processed but not processed, and therefore the urgent messages are made to respond in time; and the first consumer of the first message queue puts the message into the corresponding second theme type of the second message queue according to the priority value, and the second consumer of the corresponding second theme type consumes the message, so that the message processing efficiency is improved.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, where the present disclosure provides an electronic device, including: theprocessor 301 and thememory 302, theprocessor 301 and thememory 302 being interconnected and communicating with each other via acommunication bus 303 and/or other form of connection mechanism (not shown), thememory 302 storing a computer program executable by theprocessor 301, theprocessor 301 executing the computer program when the electronic device is running to perform the method for adjusting message priority in any of the alternative implementations of the above embodiments to implement the following functions: acquiring a message and working information sent by a message main body; acquiring a preset priority of a message; acquiring a working state coefficient according to the working information; placing the message in a first message queue; calculating a priority value of the message according to the preset priority and the working state coefficient of the message by a first consumer of the first message queue; and the first consumer of the first message queue puts the message into the corresponding second theme type of the second message queue according to the priority value, and the second consumer of the corresponding second theme type consumes the message.
The embodiment of the present application provides a computer storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program executes a method for adjusting message priority in any optional implementation manner of the foregoing embodiment, so as to implement the following functions: acquiring a message and working information sent by a message main body; acquiring a preset priority of a message; acquiring a working state coefficient according to the working information; placing the message in a first message queue; calculating a priority value of the message according to the preset priority and the working state coefficient of the message by a first consumer of the first message queue; and the first consumer of the first message queue puts the message into the corresponding second theme type of the second message queue according to the priority value, and the second consumer of the corresponding second theme type consumes the message. The computer storage medium may be implemented by any type of volatile or nonvolatile storage device or combination thereof, such as a Static Random Access Memory (SRAM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), an Erasable Programmable Read-Only Memory (EPROM), a Programmable Read-Only Memory (PROM), a Read-Only Memory (ROM), a magnetic Memory, a flash Memory, a magnetic disk, or an optical disk.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is merely a division of one logic function, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
In this document, 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.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.