CN110764923B - Task creating method and device based on message queue - Google Patents

Task creating method and device based on message queue Download PDF

Info

Publication number
CN110764923B
CN110764923B CN201810843626.7A CN201810843626A CN110764923B CN 110764923 B CN110764923 B CN 110764923B CN 201810843626 A CN201810843626 A CN 201810843626A CN 110764923 B CN110764923 B CN 110764923B
Authority
CN
China
Prior art keywords
cutting
parameter message
data
parameter
message
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
CN201810843626.7A
Other languages
Chinese (zh)
Other versions
CN110764923A (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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201810843626.7A priority Critical patent/CN110764923B/en
Publication of CN110764923A publication Critical patent/CN110764923A/en
Application granted granted Critical
Publication of CN110764923B publication Critical patent/CN110764923B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a task creating method based on a message queue, which comprises the following steps: after receiving the parameter message, judging whether the length of the parameter message exceeds a preset length threshold value; if the length of the parameter message exceeds a preset length threshold, cutting the parameter message into a plurality of groups of data, wherein the length of each group of data after cutting does not exceed the preset length threshold; storing each group of cut data into a message queue; a first task corresponding to each set of data in the message queue is created. Therefore, the creation task is not limited by the parameter length, namely, the parameter message with any length can be stored in the message queue, and the data is processed by creating the corresponding task.

Description

Task creating method and device based on message queue
Technical Field
The present invention relates to the field of data processing, and in particular, to a task creation method and device based on a message queue.
Background
A "message queue" is a container that holds messages during their transmission, and in distributed applications, communication between programs is often implemented by means of a message queue. For example, rabbitMQ, queue of Azure Storage.
However, the message queue generally has a limit on the length of each message, and if the length of the message to be transferred exceeds the upper limit of the length allowed by the message queue, the interface logic cannot put a parameter exceeding a certain number of bytes into the queue and create a task associated with the parameter.
Disclosure of Invention
In view of the above, the present invention is proposed to provide a message queue based task creation method and apparatus that overcomes or at least partially solves the above problems.
In order to achieve the above purpose, the invention provides the following specific technical scheme:
the embodiment of the invention discloses a task creating method based on a message queue, which comprises the following steps:
after receiving the parameter message, judging whether the length of the parameter message exceeds a preset length threshold value;
if the length of the data exceeds the preset length threshold, the parameter message is cut into a plurality of groups of data, wherein the length of each group of cut data does not exceed the preset length threshold;
respectively storing each group of cut data into a message queue;
a first task corresponding to each set of data in the message queue is created.
Optionally, before the parameter message is cut into multiple sets of data, the method further includes:
creating a second task for cutting the parameter message into multiple groups of data, wherein a task level relationship between the second task and the first task is a parent-child relationship.
Optionally, the cutting the parameter message into multiple groups of data includes:
acquiring a preset cutting unit, wherein the preset cutting unit is less than or equal to the preset length threshold;
and cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
Optionally, the parameter message is multiple pieces, and the cutting the parameter message into multiple groups of data includes:
determining the parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
calculating the number of data groups obtained by cutting the parameter message with the longest length by adopting the preset length threshold value, and determining the number of the data groups as the number of the cutting groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each parameter message into a plurality of groups of data based on the actual cutting unit.
Optionally, the parameter message is multiple pieces, and the cutting the parameter message into multiple groups of data includes:
determining a parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
based on the preset length threshold, cutting the parameter message with the longest length to obtain multiple groups of data, and determining the number of data groups of the cut multiple groups of data as the number of cutting groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each residual parameter message except the parameter message with the longest length into a plurality of groups of data based on the actual cutting unit.
The embodiment of the invention also discloses a task creating device based on the message queue, which comprises the following steps:
the judging unit is used for judging whether the length of the parameter message exceeds a preset length threshold value or not after the parameter message is received;
the cutting unit is used for cutting the parameter message into a plurality of groups of data if the length of the parameter message exceeds a preset length threshold, wherein the length of each group of cut data does not exceed the preset length threshold;
the storage unit is used for respectively storing each group of cut data into a message queue;
the first creating unit is used for creating a first task corresponding to each group of data in the message queue.
Optionally, the method further includes:
and the second creating unit is used for creating a second task for cutting the parameter message into multiple groups of data, and the task level relationship between the second task and the first task is a parent-child relationship.
Optionally, the cutting unit includes:
a first obtaining subunit, configured to obtain a preset cutting unit, where the preset cutting unit is smaller than or equal to the preset length threshold;
and the first cutting subunit is used for cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
Optionally, the parameter message is multiple, and the cutting unit includes:
a first determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with a longest length;
the second acquiring subunit is used for acquiring a preset length threshold;
the first calculating subunit is configured to calculate the number of data groups obtained by cutting the parameter message with the longest length by using the preset length threshold;
a second determining subunit, configured to determine the data group number as a cutting group number of each parameter message;
the second calculating subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and the second cutting subunit is used for cutting each parameter message into a plurality of groups of data based on the actual cutting unit.
Optionally, the parameter message is multiple, and the cutting unit includes:
a third determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with the longest length;
the third acquiring subunit is used for acquiring a preset length threshold;
the third cutting subunit is configured to cut the parameter message with the longest length based on the preset length threshold value, so as to obtain multiple groups of data;
a third determining subunit, configured to determine the number of data groups of the cut multiple groups of data as the number of cut groups of each parameter message;
the third calculation subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
the third cutting unit is further configured to cut each remaining parameter message except the parameter message with the longest length into multiple sets of data based on the actual cutting unit.
The embodiment of the invention also discloses a storage medium, which comprises a stored program,
and controlling the device where the storage medium is located to execute the task creating method based on the message queue when the program runs.
The embodiment of the invention discloses a processor, which is characterized in that the processor is used for running a program, wherein the task creation method based on a message queue is executed when the program runs.
By means of the technical scheme, the task creating method based on the message queue comprises the following steps: after receiving the parameter message, judging whether the parameter message exceeds a preset length threshold value; if the length exceeds a preset length threshold, the parameter message is cut into a plurality of groups of data based on a preset length unit; storing each group of data to a message queue for summarizing; the first task in each group of message queues is created. Therefore, the task creation is not limited by the parameter length, namely, the parameter message with any length can be stored in the message queue, and the corresponding task is created to process the data.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating a task creation method based on a message queue according to an embodiment of the present invention;
FIG. 2 is another flow chart of a message queue-based task creation method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram illustrating a task creating device based on a message queue according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Referring to fig. 1, a schematic flowchart of a task creation method based on a message queue according to an embodiment of the present invention is shown, and in this embodiment, the method includes the following steps S101 to S105:
s101: after receiving the parameter message, judging whether the length of the parameter message exceeds a preset length threshold value;
after the API receives the parameter message, since the message queue has a length limitation, in order to ensure that the received parameter message can be transmitted through the message queue, the length of the parameter message stored in the message queue needs to be ensured. In this embodiment, a length threshold may be preset to determine whether the received message may be stored in the message queue, and if the received parameter message exceeds the preset length threshold, it indicates that the received parameter message cannot be stored in the message queue.
The length of the parameter message can be counted by the number of characters contained in the parameter message or the number of the parameters; the preset length threshold value can be set by a technician according to actual conditions, and can be set to any value which is less than or equal to the maximum allowable data length of the message queue in order to ensure that the data stored in the message queue does not exceed the data length of the message queue.
S102: if the length exceeds a preset length threshold, the parameter message is cut into a plurality of groups of data;
the length of each cut set of data does not exceed (is less than or equal to) a preset length threshold, and the cutting of the parameter message may be performed in multiple ways or based on multiple standards, which is not limited in this embodiment. For example, under the condition that each group of data after the cutting is less than the preset length threshold, the parameter message may be equally divided, that is, each parameter message is cut into data groups with equal size, or the parameter message may be unequally divided, that is, the size of each group of data after the cutting of the parameter message may be different.
S103: respectively storing each group of cut data into a message queue;
in this embodiment, the data length of each divided group of data is less than or equal to the maximum data length of the message queue, and each group of data may be stored in the message queue in the form of data.
S104: a first task corresponding to each set of data in the message queue is created.
In this embodiment, the first task is a processing means for processing the parameter message stored in each group of message queues, and the first tasks of each group of message queues may be the same or different, and may be specifically set according to an actual situation.
In this embodiment, the parameter message larger than the preset length threshold is divided into a plurality of groups of data, each group of data is stored in the message queue, and each group of message queue task is created, so that the data of each group is processed according to the corresponding task. Therefore, the creation task is not limited by the parameter length, namely, the parameter message with any length can be stored in the message queue, and the data is processed by creating the corresponding task.
In one embodiment, the step S102 may include the following steps S1 to S2:
step S1: acquiring a preset cutting unit, wherein the preset cutting unit is less than or equal to the preset length threshold;
step S2: and cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
The cutting unit can be preset, the cutting unit can be set to be equal to a preset length threshold value, and the cutting unit can also be set to be smaller than the preset length threshold value, so that the length of each group of data after cutting is ensured not to exceed the preset length threshold value.
Because the lengths of the parameter messages are different, the preset cutting unit can cut the parameter messages into multiple groups of data with equal lengths or multiple groups of data with different lengths.
For example, when the length of the parameter message is an integer multiple of a preset cutting unit, the parameter message may be cut into multiple sets of data with equal lengths; when the length of the parameter message is not an integral multiple of the preset cutting unit, the length of the last section of data is smaller than the preset length threshold value in the process of cutting the parameter message, so that the cut data groups are not the data groups with the same length.
For example, the following steps are carried out: if the parameter message is array data, the length of the data is counted by taking the number of the parameters as a unit, the number of the parameters contained in the array is 2000, the array is cut by taking 1000 as a unit and is cut into 2 groups of data by assuming that the preset length threshold is 1000 parameters, and each group of data contains 1000 parameters.
Or, assuming that the preset length threshold is 900 parameters, the data is divided by 900 units, and the parameters are divided into 3 groups, wherein 2 groups include 900 parameters, and one group includes 200 parameters.
In some other embodiments, when the number of the acquired parameter messages is multiple, in order to ensure that each group of data cut by each piece of parameter data may not exceed a preset length threshold, the number of the cut groups may be determined according to the longest message, and then each piece of parameter message is cut, specifically:
in one embodiment, when the parameter message is a plurality of pieces, the step of cutting the parameter message into a plurality of sets of data may include the following steps S11 to S55:
step S11: determining a parameter message with the longest length in the plurality of parameter messages;
step S22: acquiring a preset length threshold;
step S33: calculating and cutting the parameter message with the longest length by adopting a preset length threshold value to obtain a data group number, and determining the data group number as the cutting group number of each parameter message;
step S44: calculating the actual cutting unit of each parameter message according to the length and the cutting group number of each parameter message;
step S55: each parameter message is cut into a plurality of sets of data based on the actual cutting unit.
By way of example: assuming that 3 parameter messages are received, wherein a first parameter message includes 2000 parameters, a second parameter message includes 1000 parameters, and a third parameter message includes 1500 parameters, it can be determined that the first parameter message is the longest, assuming that a preset length threshold is 500 parameters, it is easy to calculate that the first parameter message is cut by using the preset length threshold, the number of obtained data groups is 4, then each parameter message is respectively cut into 4 corresponding actual cutting units, that is, the actual cutting unit of the first parameter message is calculated as: 2000/4=500, the actual cutting unit of the second parameter message is: 1000/4=250, the actual cutting unit of the third parameter message is: 1500/4=375, and each parameter message is divided into 4 groups of data according to the actual cutting unit of each parameter message.
In this embodiment, the longest parameter message is cut by using the preset length threshold as the cutting unit, so that it can be ensured that the length of each group of the cut parameter messages does not exceed the preset length threshold. In addition, in this embodiment, if the lengths of the longest parameter messages are different, different numbers of the cutting groups may be obtained, and although the number of the data groups cut by each parameter message is the same, the lengths of the parameter messages are different, the obtained actual cutting units will be different, and adaptive cutting can be performed according to the difference in the lengths of the parameter messages, so as to ensure flexibility and effectiveness of data cutting.
In another embodiment, when the parameter message is multiple pieces, the parameter message is cut into multiple sets of data, which may include the following steps S111 to S555:
step S111: determining the parameter message with the longest length in the plurality of parameter messages;
step S222: acquiring a preset length threshold;
step S333: based on the preset length threshold, cutting the parameter message with the longest length to obtain multiple groups of data, and determining the number of data groups of the cut multiple groups of data as the number of cut groups of each parameter message;
step S444: calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
step S555: and cutting each residual parameter message except the parameter message with the longest length into a plurality of groups of data based on the actual cutting unit.
It should be noted that the difference between the present embodiment and the previous embodiment is mainly: in the previous embodiment, after the preset length threshold is obtained, the parameter message with the longest length is not actually cut, but through a calculation step, how many cutting groups are obtained if cutting is performed is determined, and after the actual cutting unit of each parameter message is determined, each parameter message is cut. In this embodiment, after the preset length threshold is obtained, the parameter message with the longest length is actually cut, and then after the actual cutting unit of each parameter message is determined, the remaining parameter messages except the parameter message with the longest length need to be cut.
In this embodiment, if the length of the longest parameter message is different, different numbers of the sliced groups may be obtained, and although the number of the data groups sliced by each parameter message is the same, the length of each parameter message is different, the obtained actual slicing unit will be different, and adaptive slicing can be performed according to the difference in the length of each parameter message, thereby ensuring flexibility and effectiveness of data slicing.
In another embodiment, the parameter message received by the API may include a plurality of different parameter messages, and for different parameter messages, in order to distinguish different parameter messages and associate each group of data after each data is cut, a task association manner may be adopted, specifically referring to another flowchart diagram of a task creation method based on a message queue shown in fig. 2, in this embodiment, the method may include the following steps S201 to S205:
s201: after receiving the parameter message, judging whether the parameter message exceeds a preset length threshold value;
step S201 is similar to step S101 mentioned above, and is not described herein again.
S202: if the length exceeds the preset length threshold, a second task for cutting the parameter message into multiple groups of data is created;
the second task can be a cutting task for cutting the parameter message, and the cutting is executed by creating a special cutting task (the second task), so that the task content is clear, the labor is clearly divided in the execution process, and errors are not easy to occur in the parameter message cutting process.
In this embodiment, if different parameter messages are received simultaneously or different parameter messages are received uninterruptedly, a second task may be created for each parameter message, so as to execute a corresponding cutting task by each second task; or, a second task is created for a plurality of parameter messages, and the same second task is used for executing the cutting tasks of different parameter messages respectively.
S203: cutting the parameter message into a plurality of groups of data based on a preset length unit through a second task;
step S203 is similar to step S102, and any one of the above embodiments may be optionally selected for implementation, which is not described herein again.
S204: storing each group of data into a message queue;
step S204 is similar to step S103 mentioned above, and is not described herein again.
S205: a first task corresponding to each set of data in the message queue is created.
The task hierarchy relationship between the second task and the first task is a parent-child relationship, that is, the first task is a child task of the second task. By creating a special cutting task to execute cutting and enabling the task level relationship between the cutting task and the first task corresponding to each cut group of data to be a parent-child relationship, the task levels of each cut group of data (originally belonging to the same parameter message) can be guaranteed to be consistent and are all subtasks, and the cutting task is a parent task of the child task, so that each cut group of data is guaranteed to belong to the same parent task, the task level is clear, and the subsequent accurate reverse recovery is easy to generate the parameter message.
For example, the following steps are carried out: assume that the parameter message received by the API includes: array 1 and array 2, wherein array 1 comprises 2000 parameters, and data 2 comprises 3000 parameters, for example, array 1 is [ a ] 1 ,a 2 ,a 3 …a 2000 ]The array 2 is [ b ] 1 ,b 2 ,b 3 …b 3000 ]Establishing the second task of array 1 and the second task of array 2, and after the data in array 1 and data array 2 are cut, array 1 is cut into 2 small arrays, for example, as [ a ] 1 ,a 2 ,a 3 …a 1000 ]And [ a ] 1001 ,a 1002 ,a 1003 …a 2000 ]Array 2 is cut into 3 small arrays [ b ] 1 ,b 2 ,b 3 …b 1000 ]、[b 1001 ,b 1002 ,b 1003 …b 2000 ]And [ b) 2001 ,b 2002 ,b 2003 …b 3000 ]Respectively create [ a ] 1 ,a 2 ,a 3 …a 1000 ]And [ a ] 1001 ,a 1002 ,a 1003 …a 2000 ]A first task of [ a ] 1 ,a 2 ,a 3 …a 1000 ]And [ a ] 1001 ,a 1002 ,a 1003 …a 2000 ]The first task of (a) 1 ,a 2 ,a 3 …a 2000 ]A subtask of the second task of [ b ] 1 ,b 2 ,b 3 …b 1000 ]、[b 1001 ,b 1002 ,b 1003 …b 2000 ]And [ b 2001 ,b 2002 ,b 2003 …b 3000 ]A first task of [ b ], wherein 1 ,b 2 ,b 3 …b 1000 ]、[b 1001 ,b 1002 ,b 1003 …b 2000 ]And [ b) 2001 ,b 2002 ,b 2003 …b 3000 ]The first task of (a) is [ b ] 1 ,b 2 ,b 3 …b 3000 ]A subtask of the second task.
In this embodiment, the created first task of each group of data after being cut is established with a parent-child hierarchical relationship with the second task, so that it is ensured that the first task with the same parameter belongs to one parent task.
Referring to fig. 3, a schematic structural diagram of a task creating apparatus based on a message queue according to an embodiment of the present invention is shown, where the apparatus includes:
a determining unit 301, configured to determine, after receiving a parameter message, whether a length of the parameter message exceeds a preset length threshold;
a cutting unit 302, configured to cut the parameter message into multiple groups of data if the length of the parameter message exceeds a preset length threshold, where the length of each group of cut data does not exceed the preset length threshold;
a storage unit 303, configured to store each group of cut data into a message queue respectively;
a first creating unit 304, configured to create a first task corresponding to each group of data in the message queue.
Optionally, the method further includes:
and the second creating unit is used for creating a second task which cuts the parameter message into multiple groups of data, and the task level relationship between the second task and the first task is a parent-child relationship.
Optionally, the cutting unit includes:
a first obtaining subunit, configured to obtain a preset cutting unit, where the preset cutting unit is smaller than or equal to the preset length threshold;
and the first cutting subunit is used for cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
Optionally, the parameter message is multiple, and the cutting unit includes:
a first determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with a longest length;
the second acquiring subunit is used for acquiring a preset length threshold;
the first calculating subunit is configured to calculate the number of data groups obtained by cutting the parameter message with the longest length by using the preset length threshold;
a second determining subunit, configured to determine the data group number as a cutting group number of each parameter message;
the second calculating subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and the second cutting subunit is used for cutting each parameter message into a plurality of groups of data based on the actual cutting unit.
Optionally, the parameter message is multiple, and the cutting unit includes:
a third determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with the longest length;
the third acquiring subunit is used for acquiring a preset length threshold;
the third cutting subunit is configured to cut the parameter message with the longest length based on the preset length threshold, so as to obtain multiple groups of data;
a third determining subunit, configured to determine the number of data groups of the cut multiple groups of data as the number of cut groups of each parameter message;
the third calculation subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
the third cutting unit is further configured to cut each remaining parameter message except the parameter message with the longest length into multiple sets of data based on the actual cutting unit.
By the device of the embodiment, the task creation is not limited by the parameter length, that is, the parameter message with any length can be stored in the message queue, and the data is processed by creating the corresponding task.
The judging unit, the cutting unit, the storing unit, the first creating unit and the like are all stored in a memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can set one or more, and the task creation based on the message queue is realized by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), including at least one memory chip.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing message queue-based task creation when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the task creation based on a message queue is executed when the program runs.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps:
after receiving the parameter message, judging whether the length of the parameter message exceeds a preset length threshold value;
if the length of the data exceeds the preset length threshold, the parameter message is cut into a plurality of groups of data, wherein the length of each group of cut data does not exceed the preset length threshold;
respectively storing each group of cut data into a message queue;
a first task corresponding to each set of data in the message queue is created.
Optionally, before the parameter message is cut into multiple groups of data, the method further includes:
and creating a second task for cutting the parameter message into multiple groups of data, wherein the task level relationship between the second task and the first task is a parent-child relationship.
Optionally, the cutting the parameter message into multiple groups of data includes:
acquiring a preset cutting unit, wherein the preset cutting unit is less than or equal to the preset length threshold;
and cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
Optionally, the parameter message is multiple pieces, and the cutting the parameter message into multiple groups of data includes:
determining the parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
calculating the number of data groups obtained by cutting the parameter message with the longest length by adopting the preset length threshold value, and determining the number of the data groups as the number of the cutting groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each parameter message into a plurality of groups of data based on the actual cutting unit.
Optionally, the parameter message is multiple pieces, and the cutting the parameter message into multiple groups of data includes:
determining the parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
based on the preset length threshold, cutting the parameter message with the longest length to obtain multiple groups of data, and determining the number of data groups of the cut multiple groups of data as the number of cutting groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each residual parameter message except the parameter message with the longest length into a plurality of groups of data based on the actual cutting unit.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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 phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art to which the present application pertains. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present application shall be included in the scope of the claims of the present application.

Claims (8)

1. A task creating method based on a message queue is characterized by comprising the following steps:
after receiving the parameter message, judging whether the length of the parameter message exceeds a preset length threshold value;
if the length of the parameter message exceeds a preset length threshold, creating a second task for cutting the parameter message into multiple groups of data, and cutting the parameter message into multiple groups of data through the second task, wherein the length of each group of data after cutting does not exceed the preset length threshold; when the parameter messages are multiple, determining the number of cutting groups of the longest message according to the longest parameter message and the preset length threshold, and taking the number of cutting groups as the number of cutting groups of all the parameter messages;
respectively storing each group of cut data into a message queue;
and creating a first task corresponding to each group of data in the message queue, wherein the first task is a processing means for the parameter messages stored in each group of message queue, and the first tasks corresponding to each group of data of the same parameter message are all subtasks of the second task.
2. The method of claim 1, wherein the cutting the parameter message into multiple sets of data comprises:
acquiring a preset cutting unit, wherein the preset cutting unit is less than or equal to the preset length threshold;
and cutting the parameter message into a plurality of groups of data based on the preset cutting unit.
3. The method of claim 1, wherein the parameter message is a plurality of pieces, and wherein the cutting the parameter message into a plurality of sets of data comprises:
determining the parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
calculating the number of data groups obtained by cutting the parameter message with the longest length by adopting the preset length threshold value, and determining the number of the data groups as the number of the cutting groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each parameter message into a plurality of groups of data based on the actual cutting unit.
4. The method of claim 1, wherein the parameter message is a plurality of pieces, and wherein the cutting the parameter message into a plurality of sets of data comprises:
determining the parameter message with the longest length in the plurality of parameter messages;
acquiring a preset length threshold;
based on the preset length threshold, cutting the parameter message with the longest length to obtain multiple groups of data, and determining the number of data groups of the cut multiple groups of data as the number of cut groups of each parameter message;
calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
and cutting each residual parameter message except the parameter message with the longest length into a plurality of groups of data based on the actual cutting unit.
5. A message queue-based task creation apparatus, comprising:
the judging unit is used for judging whether the length of the parameter message exceeds a preset length threshold value or not after the parameter message is received;
the second creating unit is used for creating a second task for cutting the parameter message into a plurality of groups of data if the length exceeds a preset length threshold;
the cutting unit is used for cutting the parameter message into a plurality of groups of data through the second task, wherein the length of each group of cut data does not exceed the preset length threshold; when the parameter messages are multiple, determining the number of cutting groups of the longest message according to the longest parameter message and the preset length threshold, and taking the number of cutting groups as the number of cutting groups of all the parameter messages;
the storage unit is used for respectively storing each group of cut data into a message queue;
the first creating unit is used for creating a first task corresponding to each group of data in the message queue, the first task is a processing means for the parameter messages stored in each group of message queue, and the first tasks corresponding to each group of data of the same parameter message are all subtasks of the second task.
6. The device according to claim 5, characterized in that the cutting unit comprises:
the first obtaining subunit is configured to obtain a preset cutting unit, where the preset cutting unit is smaller than or equal to the preset length threshold;
the first cutting subunit is used for cutting the parameter message into a plurality of groups of data based on the preset cutting unit;
or,
when the parameter message is multiple, the cutting unit includes:
a first determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with a longest length;
the second acquiring subunit is used for acquiring a preset length threshold;
the first calculating subunit is configured to calculate the number of data groups obtained by cutting the parameter message with the longest length by using the preset length threshold;
a second determining subunit, configured to determine the data group number as a cutting group number of each parameter message;
the second calculating subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
the second cutting subunit is used for cutting each parameter message into a plurality of groups of data based on the actual cutting unit;
or,
when the parameter message is a plurality of pieces, the cutting unit includes:
a third determining subunit, configured to determine, among the plurality of parameter messages, a parameter message with the longest length;
a third obtaining subunit, configured to obtain a preset length threshold;
the third cutting subunit is configured to cut the parameter message with the longest length based on the preset length threshold value, so as to obtain multiple groups of data;
a third determining subunit, configured to determine the number of data groups of the cut multiple groups of data as the number of cut groups of each parameter message;
the third calculation subunit is used for calculating the actual cutting unit of each parameter message according to the length of each parameter message and the number of the cutting groups;
the third cutting subunit is further configured to cut each remaining parameter message except the parameter message with the longest length into multiple sets of data based on the actual cutting unit.
7. A storage medium characterized in that the storage medium includes a stored program,
wherein the device on which the storage medium is positioned is controlled to execute the task creating method based on the message queue according to any one of claims 1-4 when the program runs.
8. A processor, for running a program,
wherein the program when running performs the message queue based task creation method of any one of claims 1-4.
CN201810843626.7A 2018-07-27 2018-07-27 Task creating method and device based on message queue Active CN110764923B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810843626.7A CN110764923B (en) 2018-07-27 2018-07-27 Task creating method and device based on message queue

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810843626.7A CN110764923B (en) 2018-07-27 2018-07-27 Task creating method and device based on message queue

Publications (2)

Publication Number Publication Date
CN110764923A CN110764923A (en) 2020-02-07
CN110764923B true CN110764923B (en) 2023-02-21

Family

ID=69327816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810843626.7A Active CN110764923B (en) 2018-07-27 2018-07-27 Task creating method and device based on message queue

Country Status (1)

Country Link
CN (1) CN110764923B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102457442A (en) * 2010-10-29 2012-05-16 金蝶软件(中国)有限公司 Message sending and reading methods and devices as well as middleware system
CN103914399A (en) * 2012-12-31 2014-07-09 中国移动通信集团公司 Disk cache method and device in parallel computer system
CN105306621A (en) * 2015-11-24 2016-02-03 北京天地互连信息技术有限公司 DNS (Domain Name Server) packet extension method based on DNS message segmentation of application layer

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0504117D0 (en) * 2005-03-01 2005-04-06 Ibm Data processing system and method
CN103455526A (en) * 2012-06-05 2013-12-18 杭州勒卡斯广告策划有限公司 ETL (extract-transform-load) data processing method, device and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102457442A (en) * 2010-10-29 2012-05-16 金蝶软件(中国)有限公司 Message sending and reading methods and devices as well as middleware system
CN103914399A (en) * 2012-12-31 2014-07-09 中国移动通信集团公司 Disk cache method and device in parallel computer system
CN105306621A (en) * 2015-11-24 2016-02-03 北京天地互连信息技术有限公司 DNS (Domain Name Server) packet extension method based on DNS message segmentation of application layer

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Early detection algorithm based on instant arriving mass data in SMS system;zhao hai;《Journal of Northeastern University (Natural Science)》;20070131;第28卷(第1期);第35页 *
一种用于拥塞网络节点缓存队列长度控制方法;姜彬彬;《计算机仿真》;20161025;第33卷(第8期);第280-283页 *

Also Published As

Publication number Publication date
CN110764923A (en) 2020-02-07

Similar Documents

Publication Publication Date Title
CN110768912B (en) API gateway current limiting method and device
CN109669776B (en) Detection task processing method, device and system
CN112346829A (en) Method and equipment for task scheduling
CN110716813A (en) Data stream processing method and device, readable storage medium and processor
CN109951494B (en) Simulation data processing method and device, simulation equipment and storage medium
CN110222936B (en) Root cause positioning method and system of business scene and electronic equipment
US10783005B2 (en) Component logical threads quantity adjustment method and device
CN106648839B (en) Data processing method and device
CN110557291A (en) Network service monitoring system
CN113641526A (en) Alarm root cause positioning method and device, electronic equipment and computer storage medium
CN110764930A (en) Request or response processing method and device based on message mode
CN109428682A (en) A kind of Message Processing confirmation method and device
CN112416534A (en) Agent-based task management method and device
CN110764923B (en) Task creating method and device based on message queue
CN110968858A (en) User authority control method and system
CN104281587B (en) A kind of method and device for establishing connection
CN112597151A (en) Data processing method, device, equipment and storage medium
CN108021448B (en) Kernel space optimization method and device
CN110888723A (en) Timing task processing method and device
CN112559050A (en) Method and device for processing concurrency number of client asynchronous request information
CN109600245B (en) Automatic configuration method and device for server
CN110659296A (en) Storage method, device, equipment and computer readable medium
CN115442262A (en) Resource evaluation method and device, electronic equipment and storage medium
CN110969461B (en) Method and device for processing public number information, storage medium and processor
CN109508446B (en) Log processing method and device

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