WO2013143050A1 - Service processing method, execution unit and system for distributed operating system - Google Patents

Service processing method, execution unit and system for distributed operating system Download PDF

Info

Publication number
WO2013143050A1
WO2013143050A1 PCT/CN2012/073003 CN2012073003W WO2013143050A1 WO 2013143050 A1 WO2013143050 A1 WO 2013143050A1 CN 2012073003 W CN2012073003 W CN 2012073003W WO 2013143050 A1 WO2013143050 A1 WO 2013143050A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
execution unit
processing
processed
queue
Prior art date
Application number
PCT/CN2012/073003
Other languages
French (fr)
Chinese (zh)
Inventor
曹俊
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2012/073003 priority Critical patent/WO2013143050A1/en
Priority to CN201280001510.XA priority patent/CN104145260B/en
Publication of WO2013143050A1 publication Critical patent/WO2013143050A1/en

Links

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

Definitions

  • the present invention relates to the field of distributed technologies, and in particular, to a service processing method, an execution unit, and a system of a distributed operating system.
  • the distributed operating system is a solution for solving large-scale computing by executing jobs in parallel by multiple hosts, and is widely used in data mining, media processing, and scientific research.
  • Amazon Simple Queue Service provides a scalable and reliable messaging framework that is a great way to build a loosely coupled distributed operating system.
  • the distributed operation system based on SQS technology transfers and distributes task information to each execution host of the system through SQS queue, and realizes large-scale calculation by executing jobs in parallel.
  • the Cloud MapReduce technology in the processing of the Map subtask, multiple processing hosts are allowed to process the same input message, and the message is output to the same Reduce queue.
  • the Reduce queue is used as the input of the Reduce subtask, and the output message contains three identifiers. : Executes the host ID, mapID, and message ID, and writes the processing record of the Ma subtask to SDB (SimpleDB) before output.
  • SDB SimpleDB
  • the processing host obtains the message from the Reduce queue the three labels of the message are recorded in the SDB, and the SDB is queried for the execution host ID list corresponding to the MapID.
  • the output of one of the execution host IDs is selected, and the output of the other execution host IDs is discarded, so that the duplicate messages output by the Map subtask are removed, and are no longer brought into the processing of the Reduce subtask below.
  • an object of the embodiments of the present invention is to provide a service processing method, an execution unit, and a system for a distributed operating system, which are applicable to the purpose of removing duplicate messages in any task in the multitasking process, and have good versatility.
  • an embodiment of the present invention provides a service processing method for a distributed operating system, where an execution unit in each service step performs the following operations for each pending message retrieved from an input queue of the service step. :
  • the current execution unit runs a service processing program of the service step where the execution unit is located for a message to be processed obtained from the input queue, and generates at least one service processing result message;
  • the current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit
  • the present invention further provides an execution unit of a distributed operating system, configured to process, in a service step in which it is located, each pending message retrieved from an input queue, the execution unit comprising:
  • a service processing unit configured to: for a pending message obtained from the input queue, run a service processing program of the service step where the execution unit is located, generate at least one service processing result message; and process a result saving unit, which is to be generated
  • the service processing result message is stored in a temporary queue corresponding to the execution unit;
  • the first processing result is stored in the judging unit, and is configured to determine whether the other execution unit has stored the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, if not,
  • the temporary queue corresponding to the current execution unit is used as the current queue, and if so, the processing completion judgment unit is triggered to work;
  • the processing completion judging unit is configured to determine whether the to-be-processed message is completely processed by other execution units, and if the incomplete processing is completed, the pending queue of the other execution unit is already stored in the pending message.
  • the temporary queue for processing the obtained service processing result message is used as the current temporary queue;
  • the processing result transfer unit is configured to transfer all the service processing result messages in the current temporary queue to the output queue, and the pending message is completely processed.
  • Another aspect of the present invention also provides a distributed operating system comprising a plurality of the above-described execution units and a storage unit storing a message record table.
  • each execution unit transfers the service processing result message processed for one to-be-processed message to the output queue, it is determined whether there is no other execution unit that will process the pending item.
  • the service processing result message obtained by the message is stored in the corresponding temporary queue. If the judgment result is not, the current execution unit will transfer the service processing result message outputted by the current execution unit to the output queue. Otherwise, the current execution unit
  • the business process result message that was previously processed by other execution units is transferred to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the service processing result message and finally sends it to the output queue, avoiding outputting duplicate service processing results to the output queue for the same pending message. Message. And the solution can be applied to the various business steps of the distributed business system, so it is more versatile.
  • FIG. 1 is a flowchart of a service processing method of a distributed operating system according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a service processing method of a distributed operating system according to Embodiment 2 of the present invention
  • FIG. 4 is a schematic diagram of a processing procedure of an execution unit of an Nth service step in Embodiment 3 of the present invention
  • FIG. 5 is a flowchart of a service processing method of a distributed operating system according to Embodiment 3 of the present invention
  • 6 is a schematic diagram of an application example of a service processing method of a distributed operating system according to an embodiment of the present invention
  • Figure ⁇ is a schematic diagram of another application example of the service processing method of the distributed operating system provided by the embodiment of the present invention.
  • FIG. 8 is a schematic diagram of another application example of a service processing method of a distributed operation system according to an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of another application example of a service processing method of a distributed operating system according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of an execution unit of a distributed operating system according to an embodiment of the present invention
  • FIG. 11 is a schematic diagram of an execution unit of a distributed operating system according to another embodiment of the present invention.
  • a first embodiment of the present invention provides a service processing method for a distributed operating system. As shown in FIG. 1, in the method, an execution unit in each service step is for each item to be taken from an input queue of the service step. Processing the message performs the following operations:
  • Step S101 The current execution unit runs at least one service processing result message for the service processing program of the service step where the execution unit is located, for a message to be processed obtained from the input queue.
  • Step S102 The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit.
  • Step S103 determining whether there are other execution units storing the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, using the temporary queue corresponding to the current execution unit as The current temporary queue is executed, and step S105 is performed; if yes, step 104 is performed.
  • Step S104 It is determined whether the to-be-processed message has been completely processed by other execution units. For the case that the processing is not completely processed, the service processing result of processing the pending message in the temporary queue of the other execution unit is already stored. The temporary queue of the message acts as the current temporary queue, then Step S105 is performed.
  • Step S105 The current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed by the current execution unit.
  • each execution unit transfers the service processing result message processed for one to-be-processed message to the output queue, it is determined whether no other execution unit will process the The service processing result message obtained by the message to be processed is stored in the corresponding temporary queue. If the judgment result is not, the current execution unit will transfer the service processing result message outputted by the current execution unit to the output queue. Otherwise, The current execution unit transfers the business process result message that was previously processed by other execution units to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the service processing result message and finally sends it to the output queue, avoiding outputting duplicate service processing results to the output queue for the same pending message. Message.
  • the method provided by the embodiment of the present invention is a solution that can be applied to various service steps of a distributed service system, and therefore is more versatile.
  • the result message is stored in the corresponding temporary queue, but since the execution unit A determines that the execution unit B has processed the message when executing to step S103, and has already stored the output message in the temporary queue of the execution unit B, Therefore, the execution unit A still performs step S101 and step S102 to execute the business processing program on the same pending message, which actually causes waste of processing resources.
  • the execution unit in each service step is from the The following steps are taken to retrieve each pending message from the input queue of the business step:
  • Step S201 determining whether there is no other execution unit to store the service processing result outputted by the current execution unit to be processed into the temporary queue corresponding to the other execution unit, such as If not, step 202 is performed; if yes, step S205 is performed.
  • Step S202 The current execution unit runs a service processing procedure of the service step of the execution unit for the acquired to-be-processed message, and generates at least one service processing result message.
  • Step S203 The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit.
  • Step S204 determining whether there are other execution units storing the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, using the temporary queue corresponding to the current execution unit as The current temporary queue is executed, and step S206 is performed; if yes, step 205 is performed.
  • Step S205 It is determined whether the to-be-processed message has been completely processed by other execution units. For the case that the processing is not completely processed, the service processing result of processing the pending message in the temporary queue of the other execution unit is already stored. The temporary queue of the message is used as the current temporary queue, and then step S206 is performed.
  • Step S206 The current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed by the current execution unit.
  • the method provided in this embodiment can not only output a repeated service processing result message to the output queue for the same pending message, but also determine whether the current execution unit performs a service processing procedure on a to-be-processed message. There is no other execution unit that stores the service processing result message outputted by the processing of the to-be-processed message in the temporary queue corresponding to the other execution unit. If the judgment result is not, the current execution unit will process the item to be processed. Messages are processed to avoid wasting processing resources.
  • Embodiment 3 Embodiment 3
  • the entire service model is composed of multiple service steps (steps), and the relationships between the business steps are concatenated, as shown in FIG.
  • Each business step consists of an input queue, an execution unit, an output queue, and a message log table to record the processing of the message.
  • the StepN queue in Figure 3 refers to the input queue of the execution unit of the Nth business step. For the message to be processed, it is also the output queue of the execution unit of the N-1th business step for collecting and transmitting the generated new message.
  • the execution unit of each business step is the smallest execution unit in the business, and each business step can have multiple execution units.
  • the execution unit gets the message from the input queue, runs the business program to process the message, and puts the generated message into the output queue.
  • the message record table can be stored in the SDB, which can be a non-relational data storage database that can be scaled and highly available.
  • the structure of the data is specially designed. For example, each row of data is an item, each entry may have multiple attributes, and each attribute may have multiple values (value ).
  • the message ID (MsgID) of each to-be-processed message is taken as an entry, and the attributes in each entry include the receiving time (ReceiveTime), the execution unit ID (WorkerDD), and the commit time (CommitTime). ), temporary queue address ( TempQueueURL ) and completion time ( FinishTime ).
  • a temporary queue is created. All new messages generated during message processing are placed in the temporary queue, and the address of the temporary queue is written in the message record table. The new message corresponds to the entry in the "temporary queue address" attribute.
  • the writing conditions of the message recording table are specifically limited in the present invention, and will be described in detail in the subsequent steps.
  • FIG. 4 is a schematic diagram showing the processing procedure of the execution unit of the Nth service step, and it can be seen that the execution unit of the Nth service step outputs the queue from the execution unit of the N-1th business step (also the Nth business step).
  • Obtaining a message in the input queue of the execution unit step 1 in Fig. 4
  • writing a message acquisition record for the acquired message in the message record table step 2 in Fig.
  • the Nth business step is The execution unit transfers the message in the temporary queue to the output queue (step 5 in Figure 4) and writes the completion record in the message record table (step 6 in Figure 4).
  • the execution of an execution unit of the Nth service step in the case that the writing step is normally completed, in fact, in the steps of the method provided by the embodiment of the present invention, Consider the conditional constraints of writing to achieve the problem of preventing duplicate message output, as detailed below.
  • the service processing method of the distributed operating system provided by this embodiment includes the following steps:
  • Step S501 The execution unit acquires a message from the input queue as the currently processed message.
  • the execution unit is not limited to an execution unit at a specific service step.
  • the input queue is a queue formed by the message output by the previous service step of the service step where the execution unit is located; when the execution unit is the first service
  • the execution unit of the step the input queue is the queue formed by the message originally received by the system.
  • Step S502 The execution unit starts to write a message acquisition record to the message record table by using the acquired ID of the to-be-processed message, and the process of writing includes: to the item corresponding to the ID of the acquired message (Item)
  • the receiving time " attribute joins the execution unit to get the message, and adds the ID of the execution unit to the "execution unit ID" attribute in the same entry.
  • Step S503 determining whether the value of the "commit time" attribute in the entry written in step S502 is empty, if yes, the execution unit succeeds in step S502, and proceeds to step S504; otherwise, indicates the execution unit
  • the writing in step S502 fails, the data written in step S502 is cleared, and then step 510 is performed.
  • Step S504 After confirming that the writing is successful in step S503, the executing unit runs the business program to process the acquired pending message, and stores the new message generated during the processing (ie, the business processing result message) into the execution unit. In the temporary queue.
  • the "commit time" in an entry is that the message corresponding to the entry has been processed by an execution unit and the business process result message is stored in the temporary queue, it is added, so when the step When it is confirmed in S503 that the writing is successful, it indicates that the value of the "commit time” attribute in the entry of the acquired message is null, further indicating that the pending message has not been successfully processed by other execution units and the business processing result message is stored. It is meaningful to the temporary queue, so the execution unit continues to process the obtained message, which can further save processing resources.
  • Step S505 Writing a message processing record with the ID of the message to be processed, the process of writing includes: starting a "commit time” and a "temporary queue address" in an entry corresponding to the ID of the to-be-processed message.
  • the two attributes are respectively added to the time when the generated service processing message is stored in the temporary queue in step S504 and the address of the temporary queue.
  • Step S506 It is judged whether the value of the "commit time" attribute in the entry written in step S505 is empty. If yes, the execution unit succeeds in the writing in step S505, and the temporary queue address written in step S505 is obtained. As the current temporary queue address, step S507 is continued; otherwise, the write fails, and the data written in step S505 is cleared, and then step S510 is performed.
  • step S503 For the reason that it is determined in step S503 that the acquisition message record is successfully written, but the subsequent step S506 is still based on the similar submission to determine whether the processing message is successfully written, the reason is: at a certain execution unit in step S502
  • no other execution unit has processed the acquired message, that is, the process is judged to be successful in step S503, but in the process of processing the acquired message by the execution unit, There may be other execution units that process the acquired same message and store it in the temporary queue, thereby updating the entry in the message record table about the message, so that the attributes of "commit time" and "temporary queue address" are both It is no longer empty. If it is no longer judged according to the same write restriction condition in the subsequent step S506, it will cause repeated processing and finally output a new message that is repeated.
  • Step S507 Obtain a message from the corresponding temporary queue according to the current temporary queue address (that is, obtain each service processing result message), and put it into the output queue until the temporary queue is emptied.
  • Step S508 Write the write completion record in the entry to the entry corresponding to the message ID of the to-be-processed message in the message record table, and specifically include: transferring all the service processing messages in the current temporary queue to the output queue The time is written to the "Completion Time" attribute in the entry.
  • Step S509 The currently processed message is deleted from the input queue, and the process returns to step S501.
  • Step S510 When the result of the determination in step S503 or step S506 is no, the value of all the attributes in the entry of the current message to be processed is obtained from the message record table.
  • step S510 when an execution unit executes step S510, it means that the other execution units have processed the same message in the input queue, but whether the generated new message has been completely put into the output queue is determined by the subsequent judgment step.
  • Step S511 It is judged whether the value of the "Completion Time" attribute in the attribute obtained in step S510 is empty, and if not, the process returns to step S501; if yes, the process proceeds to step S512.
  • Step S512 The value of the "temporary queue address" attribute in the entry of the current pending message As the current temporary queue address, then return to step S507.
  • step S511 determines whether the same pending message has been completely processed by other execution units, and the generated service processing result message has been output to the output queue, so the execution unit should not re-book this The message is subsequently processed, and the next message should be retrieved from the input queue again, that is, the process returns to step S501.
  • step S511 If the result of the determination in step S511 is YES, it indicates that the other execution units have finished processing the same message in the input queue, and the new message outputted after the processing has been written into the temporary queue of the other execution unit, and is also written.
  • the message processing record At this time, according to step S512, the current execution unit calls up the temporary queue address of the execution unit that previously wrote the message processing record, and the address of the temporary queue is used as the address of the current temporary queue, and then proceeds to the temporary queue by performing step S507.
  • the new message that has been output is placed in the output queue of this business step, thereby preventing multiple execution units from repeatedly outputting the same new message.
  • Figure 6 shows the entire process of obtaining a message from an input queue with only one execution unit in the Nth business step. As shown in FIG. 6, the process specifically includes:
  • Step S601 The execution unit acquires a pending message from the input queue.
  • Step S602 The execution unit writes a message acquisition record to the to-be-processed message in the message record table. Since the message is obtained by the execution unit from the input queue for the first time, there may not be any message in the message record table. An entry, so in this step, a new entry is created for the acquired message, and the values of the two attributes of the receiving time and the execution unit ID contained in the message acquisition record are filled in.
  • Step S603 Since no other execution unit acquires the message before, in the message record table, the value of the submission time attribute of the entry corresponding to the message is null, so the message record table is successfully written, and the execution unit is notified.
  • Step S604 The execution unit acquires a business processing program of the business step of the message to be processed for the strip, and stores the output new message in the temporary queue.
  • Step S605 The execution unit starts to input an entry for the to-be-processed message in the message record table. Writes a message processing record, including the write commit time and the temporary queue address where the output message is stored.
  • Step S606 It is determined in step S605 that the write message processing record is successfully written, and the execution unit is notified.
  • Step S607 The execution unit moves all the messages in the temporary queue to the output queue.
  • Step S608 In the execution unit item message record table, the message completion record is written for the entry corresponding to the to-be-processed message, that is, the value of the completion time attribute is added to the entry.
  • Step S609 It is determined that the write message completion record is successfully written, and the execution unit is notified.
  • Step S610 The execution unit deletes the previously processed message from the input queue.
  • Figure 7 shows the overall processing of multiple execution units getting the same message from the input queue in the Nth business step. Due to the nature of the SQS mechanism, multiple execution units that acquire messages from the same input queue may acquire the same message, and in the SQS mechanism, allow multiple execution units to simultaneously process the same message, new messages generated in the present invention. They are all put into their respective temporary queues, but through the conditional write mechanism illustrated in Figure 5, only one execution unit's output message processed by the message will be placed in the output queue, ensuring that there will be no duplicate processing results. Put in the output queue.
  • the process specifically includes:
  • Step S701 The execution unit 1 obtains the message a from the input queue.
  • Step S702 The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time” and "execution unit ID” in the entry.
  • the time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time” attribute in the entry of the message a is empty), and the writing is determined. success.
  • Step S703 After that, the execution unit 2 acquires the same message a from the input queue.
  • Step S704 The execution unit 2 also starts writing a message acquisition record to the message record table, that is, adding the time of the execution unit 2 to the message a to the two attributes of the "reception time” and the "execution unit ID" of the entry of the message a And the ID of the execution unit 2; since the value of the "commit time” attribute in the entry of the message a is still empty in the message record table at this time, the write operation of the write message acquisition record of the execution unit 2 is also satisfied. Write conditions to determine that the write was successful.
  • the value of the execution unit ID attribute in the entry of the message a includes two: the ID of the execution unit 1 and the ID of the execution unit 2; and the value of the "reception time" attribute of the entry also has two: execution unit 1 The time at which the message a is acquired and the time at which the execution unit 2 acquires the message a.
  • Step S705 The service program running the Nth business step of the execution unit 1 processes the message a obtained, and generates a new message to be stored in the temporary queue 1.
  • Step S706 The execution unit 2 also processes the message A of the Nth business step to process the message a obtained, and generates a new message to be stored in the temporary queue 2.
  • the method provided by the embodiment of the present invention is a service processing method of a distributed operation system
  • the service programs run by multiple execution units in the same service step are the same, so the execution unit 1 and the execution are performed.
  • the new message output by unit 2 processing the same message a is also the same (number of messages, content and type).
  • Step S707 Since the execution unit 1 completes the processing of the message a first, the execution unit 1 first starts writing the message processing record to the message record table, that is, the "submission time” in the entry corresponding to the message a in the message record table. "The time at which the join execution unit 1 stores the new message obtained by processing the message a into the temporary queue 1, and the address of the temporary queue 1 in which the new message of the execution unit 1 is stored in the "temporary queue address” attribute is added; When the unit 1 writes the message processing record for the message a, the value of the "commit time” attribute in the entry of the message a is still empty, so the writing condition is satisfied, and the writing is confirmed to be successful (step S708).
  • Step S709 After confirming that the message processing record is successfully written, the execution unit 1 acquires the message from the temporary queue 1 and starts to transfer to the output queue.
  • Step S710 When the execution unit 1 has not completely transferred all the messages in the temporary queue 1 to the output queue, the execution unit 2 starts writing the message processing record to the message record table, that is, the entry corresponding to the message a in the SDB.
  • the "commit time" in the joining execution unit 2 stores the new message obtained by processing the message a into the temporary queue 2, and adds the temporary queue 2 of the new message that the execution unit 2 stores the output to the "temporary queue address" attribute.
  • step S711 Since the message processing record is written to the message a at the execution unit 2, the value of the "commit time" attribute in the entry of the message a has been added to the execution unit 1 in step S707, and the resulting new message is stored in the temporary queue 1 Since the write condition is not satisfied in this step, the write failure is confirmed (step S711).
  • Step S712 The execution unit 2 receives the failure of the message processing record write failure for the message a. After knowing, the value of each attribute in the entry of the message a is read from the message record table, the value of the "temporary queue address" attribute is obtained, and the address of the temporary queue 1 represented by the value is taken as the temporary to be operated. Queue address.
  • Step S713 The execution unit 2 continues to obtain the remaining messages from the temporary queue 1 according to the address of the temporary queue 1, and transfers to the output queue.
  • Step S714 The execution unit 1 writes a message completion record to the entry of the message record table for the message a, and the writing is successful.
  • Step S715 The execution unit 2 writes a message completion record to the entry of the message record table for the message a, and the writing is successful.
  • Step S716 The execution unit 1 deletes the message a from the input queue.
  • Step S717 Execution unit 2 deletes the message from the input queue.
  • step S716 if the message a has been successfully deleted in step S716, the deletion action in step S717 is still performed, but only when the actual deletion is found, the message a does not exist, but the result of the successful deletion can still be returned.
  • FIG. 8 is a flowchart of implementing message reprocessing after a certain execution unit in the Nth service step fails in the message processing process in the embodiment of the present invention, which specifically includes: Step S801: The execution unit 1 acquires the message a from the input queue.
  • Step S802 The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time” and "execution unit ID” in the entry.
  • the time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time” attribute in the entry of the message a is empty), and the writing is determined. success.
  • Step S803 The execution unit 1 starts the business program running the Nth business step to process the message a obtained, and simultaneously stores the generated new message into the temporary queue 1.
  • Step S804 The execution unit 1 fails during the execution of the business program.
  • Step S805 Execution unit 2 acquires the same message a from the input queue.
  • Step S806 The execution unit 2 also starts to write a message acquisition record to the message record table, that is, adding the execution unit 2 to the two items of the "reception time” and the "execution unit ID" of the entry of the message a to obtain the message a.
  • Time and ID of execution unit 2 since the value of the "commit time” attribute in the entry of the message a is still empty in the message record table at this time, the write operation of the write message acquisition record of the execution unit 2 is also The write condition is met and the write is determined to be successful.
  • Step S807 The execution unit 2 also runs the business program of the Nth business step to process the message a obtained, and generates a new message to be stored in the temporary queue 2.
  • Step S808 After processing the message a and storing all the generated new messages into the temporary queue 2, the execution unit 2 starts writing the message processing record to the message record table, that is, corresponding to the message a in the message record table.
  • the "commit time" in the entry joins the execution unit 2 to store the new message obtained by processing the message a into the temporary queue 2, and the temporary queue for adding the new message of the execution unit 2 to the output of the "temporary queue address" attribute.
  • Step S809 After the acknowledgment message processing record is successfully written, the execution unit 2 transfers all the messages in the temporary queue 2 of the execution unit 2 to the output queue.
  • Step S810 After the execution unit 2 transfers all the messages in the temporary queue 2, write a message completion record to the message record table for the message a, that is, write to the "Completion Time" attribute in the entry corresponding to the message a. Execution unit 2 transfers the time in temporary queue 2. Step S811: The execution unit 2 deletes the processed message a from the input queue.
  • FIG. 9 is a flow chart showing the re-processing of a message after a failure of an execution unit in the Nth service step after the end of the message processing in the embodiment of the present invention, specifically including:
  • Step S901 The execution unit 1 acquires the message a from the input queue.
  • Step S902 The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time” and "execution unit ID” in the entry.
  • the time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time” attribute in the entry of the message a is empty), and the writing is determined. success.
  • Step S903 The execution unit 1 starts the business program running the Nth business step to process the message a obtained, and simultaneously stores the generated new message into the temporary queue 1.
  • Step S904 After processing the message a and storing all the generated new messages into the temporary queue 1, the execution unit 1 starts writing the message processing record to the message record table, that is, corresponding to the message a in the message record table.
  • the "commit time" in the entry joins the time when the execution unit 1 stores the new message obtained by processing the message a into the temporary queue 1, and the temporary queue that adds the new message of the execution unit 1 to the output to the "temporary queue address" attribute. Address of 1; Since the value of the "commit time" attribute in the entry of the message a is still empty when the execution unit 1 writes the message processing record for the message a, the write condition is satisfied, and the write is confirmed to be successful.
  • Step S905 After confirming that the message processing record is successfully written, the execution unit 1 acquires a message from the temporary queue 1 of the execution unit 1, and starts to transfer to the output queue.
  • Step S906 In the process of transferring the message, the execution unit 1 fails, and the message in the temporary queue 1 is not completely transferred.
  • Step S907 The execution unit 2 acquires the same message a from the input queue.
  • Step S908 The execution unit 2 also starts to write a message acquisition record to the message record table, that is, adding the execution unit 2 to the two items of the "reception time” and the "execution unit ID" of the entry of the message a to obtain the message a. Time and ID of execution unit 2.
  • Step S909 Since the value of the "commit time" attribute in the entry of the message a has been successfully written in the non-empty value in step S904 in the message record table at this time, the write message of the unit 2 is executed in step S908. The write operation to get the record does not satisfy the write condition, and the write failure is determined.
  • Step S910 After obtaining the write failure of the message processing record, the execution unit 2 obtains the attribute values in the entry of the message a from the message record table, and obtains the attribute value of the temporary queue address, which is the address of the temporary queue 1 in this example. .
  • Step S911 The execution unit 2 transfers all the messages in the temporary queue 1 to the output queue according to the address of the temporary queue 1.
  • Step S912 After the execution unit 2 completely transfers the messages in the temporary queue 2, write a message completion message to the SDB for the message a, that is, write the execution unit to the "Completion Time” attribute in the entry corresponding to the message a. 2 Transfer the time in the temporary queue 2.
  • Step S913 The execution unit 2 deletes the processed message a from the input queue.
  • the subsequent execution unit 2 will not only Repeatedly executing the business processing program for the same message a, and will continue to store the output new message in its corresponding temporary queue 2, and further transfer all the messages in the temporary queue 2 to the output queue, but actually, before The same processing result of the item in the temporary queue 1 has been transferred to the input by the execution unit 1. Out of the queue, so this will cause problems with duplicate processing results for the same message output.
  • An embodiment of the present invention further provides an execution unit of a distributed operation system, where the execution unit is configured to process each pending message taken from an input queue in a service step in which it is located, as shown in FIG.
  • the execution unit includes:
  • the service processing unit 1001 is configured to generate, according to a to-be-processed message obtained from the input queue, a service processing program that runs the service step where the execution unit is located, and generate at least one service processing result message;
  • the processing result saving unit 1002 is configured to store the generated service processing result message in a temporary queue corresponding to the execution unit;
  • the first processing result is stored in the judging unit 1003, and is configured to determine whether the other execution unit has not yet stored the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, if not, The temporary queue corresponding to the current execution unit is used as the current queue J
  • the processing completion determining unit 1004 is configured to determine whether the to-be-processed message is completely processed by other execution units, and if the information is not completely processed, the pending queue of the other execution unit is already stored in the pending message.
  • the temporary queue for processing the obtained service processing result message is used as the current temporary queue;
  • the processing result transfer unit 1005 is configured to transfer all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed.
  • the processing completion judgment unit first determines whether the device still returns No other execution unit stores the service processing result message obtained by processing the to-be-processed message into the corresponding temporary queue. If the judgment result is not, the processing result transfer unit in the execution unit outputs the execution unit. The business process result message is transferred to the output queue; otherwise, the process result transfer will transfer the business process result message that has been processed by other execution units to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the business processing result message. It is sent to the output queue to avoid outputting duplicate service processing result messages to the output queue for the same pending message.
  • the execution unit provided in the embodiment of the above execution unit ensures that duplicate service processing result messages are not output to the output queue for the same pending message, but may also occur.
  • execution unit B execution units that perform the same business process on the message to be processed
  • the output service processing result message is stored in the corresponding temporary queue, but since the execution unit A transfers the service processing result message in the temporary queue to the output queue, it is determined that the execution unit B has processed the message.
  • the output message has been stored in the temporary queue of execution unit B, but execution unit A still executes the business processing program for the same pending message, which actually causes waste of processing resources.
  • the second processing result is added to the judgment unit on the basis of the above embodiment. 1006.
  • the second processing result storage determining unit 1006 is configured to determine, before the service processing unit works, whether another execution unit stores the service processing result message outputted by the processing of the to-be-processed message into its corresponding temporary queue. If not, the service processing unit 1001 is notified to perform the operation; if so, the notification processing completion unit 1004 performs the operation.
  • a message record table is created for each service step, and an entry is created in the message record table for each pending message in the input queue of the corresponding service step.
  • the execution unit shown in Figs. 10 and 11 further includes means for writing various records in the message record table, and the corresponding judgment condition is also determined based on whether or not the write record is successful.
  • the execution unit may further include a processing record writing unit, configured to: after the processing result saving unit stores all the service processing result messages generated by processing the processing message into the temporary queue corresponding to the current execution unit, To the message record table corresponding to the pending message A message processing record is written in the entry, and the condition for successful writing is that the message processing record in the entry is empty.
  • the first processing result storage unit 1003 may include: a processing record writing determining unit, configured to determine whether the processing record writing unit writes the message processing record to the message recording table for the to-be-processed message, if If the write succeeds, it is determined that no other execution unit stores the service processing result message outputted by the processing of the pending message into the temporary queue corresponding to the other execution unit. If the write fails, it is determined that other execution units will The service processing result message outputted by the processing of the to-be-processed message is stored in a temporary queue corresponding to the other execution units.
  • the execution unit may further include an acquisition record writing unit, configured to: after the execution unit acquires a to-be-processed message from the input queue, to the message record table The message acquisition record is written in the entry corresponding to the processing message, and the condition for successful writing is that the message processing record in the entry is empty.
  • an acquisition record writing unit configured to: after the execution unit acquires a to-be-processed message from the input queue, to the message record table The message acquisition record is written in the entry corresponding to the processing message, and the condition for successful writing is that the message processing record in the entry is empty.
  • the second processing result storage unit 1006 includes: an acquisition record writing determination unit, configured to determine whether the acquisition record writing unit writes a message to the message record table for the to-be-processed message to obtain whether the record is successful.
  • execution unit shown in FIG. 10 and FIG. 11 may further include a completion record writing unit, configured to: after the processing result transfer unit transfers all the service processing result messages in the current temporary queue to the output queue, Writing a message completion record in an entry corresponding to the to-be-processed message in the message record table;
  • the processing completion judging unit includes: a completion record writing judging unit, configured to determine whether a message completion record has been written in an entry corresponding to the to-be-processed message, and if it has been written, determining that the to-be-processed message has been executed by another The unit is completely processed, and if it has not been written, it is determined that the pending message has not been completely processed by other execution units.
  • another embodiment of the present invention provides a distributed operating system including an execution unit of the above-described embodiments and a storage unit that stores a message recording table.
  • the unit may further include: a deleting unit, configured to delete the to-be-processed message from the input queue after the processing result forwarding unit processes the to-be-processed message.
  • the disclosed systems, devices, and parties The law can be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions may be stored in a computer readable storage medium, including instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform all of the methods described in various embodiments of the present invention or Part of the steps.
  • the foregoing storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .

Abstract

A service processing method, execution unit and system for a distributed operating system. The method comprises the following operations executed by the execution unit in each service step: as for an acquired message to be processed, a current execution unit launches a service processing program of the service step to generate a service processing result message; the generated service processing result message is stored in a corresponding temporary queue; it is determined whether there are no other execution units that store the result message of service processing produced by processing the message to be processed in the temporary queue corresponding to other execution units. If no, the temporary queue corresponding to the current execution unit is determined as the current temporary queue, and all the service processing result messages of said current temporary queue are transferred to an output queue; If yes, it is determined whether said message to be processed has been fully processed by other execution units.

Description

一种分布式作业系统的业务处理方法、 执行单元和系统 技术领域  Service processing method, execution unit and system of distributed operation system
本发明涉及分布式技术领域,尤其涉及一种分布式作业系统的业务处理方 法、 执行单元和系统。  The present invention relates to the field of distributed technologies, and in particular, to a service processing method, an execution unit, and a system of a distributed operating system.
背景技术 Background technique
分布式作业系统是一种通过多个主机并行执行作业来解决大规模计算的 方案, 被广泛应用于数据挖掘、 媒体处理和科学研究领域中。  The distributed operating system is a solution for solving large-scale computing by executing jobs in parallel by multiple hosts, and is widely used in data mining, media processing, and scientific research.
目前, Amazon Simple Queue Service (SQS)提供了一个可伸缩且可靠的消 息传递框架, 是构建松散耦合式分布式作业系统的好方法。 基于 SQS技术的 分布式作业系统通过 SQS队列把任务信息传递和分配到系统的各个执行主机, 通过并行执行作业来实现大规模计算。  Currently, Amazon Simple Queue Service (SQS) provides a scalable and reliable messaging framework that is a great way to build a loosely coupled distributed operating system. The distributed operation system based on SQS technology transfers and distributes task information to each execution host of the system through SQS queue, and realizes large-scale calculation by executing jobs in parallel.
在分布式作业系统中, 有时经常因为故障执行主机的故障恢复或者 SQS 本身允许多个处理主机处理同一消息的机制, 导致经常输出重复消息。现有技 术中也尝试在一定程度上緩解这个问题。  In a distributed operating system, sometimes a failure recovery of a host is performed due to a failure or a mechanism in which the SQS itself allows multiple processing hosts to process the same message, resulting in frequent output of duplicate messages. The prior art also attempts to alleviate this problem to some extent.
例如在 Cloud MapReduce技术中, 在 Map子任务的处理中允许多个处理 主机处理同一个输入消息, 并输出消息到同一个 Reduce队列, Reduce队列作 为 Reduce子任务的输入, 输出的消息包含三个标识: 执行主机 ID、 mapID和 消息 ID, 并在输出前把 Ma 子任务的处理记录写入 SDB ( SimpleDB )中。 在 Reduce子任务中, 处理主机从 Reduce队列中获取消息后, 把消息的 3个标记 录在 SDB中, 并在 SDB中查询该 MapID对应的执行主机 ID列表, 如果有多 个执行主机 ID, 则随即选择其中一个执行主机 ID的输出, 其他执行主机 ID 的输出将被抛弃, 从而将 Map子任务输出的重复消息进行去除, 不再带入到 下面的 Reduce子任务的处理过程中。  For example, in the Cloud MapReduce technology, in the processing of the Map subtask, multiple processing hosts are allowed to process the same input message, and the message is output to the same Reduce queue. The Reduce queue is used as the input of the Reduce subtask, and the output message contains three identifiers. : Executes the host ID, mapID, and message ID, and writes the processing record of the Ma subtask to SDB (SimpleDB) before output. In the Reduce subtask, after the processing host obtains the message from the Reduce queue, the three labels of the message are recorded in the SDB, and the SDB is queried for the execution host ID list corresponding to the MapID. If there are multiple execution host IDs, The output of one of the execution host IDs is selected, and the output of the other execution host IDs is discarded, so that the duplicate messages output by the Map subtask are removed, and are no longer brought into the processing of the Reduce subtask below.
但是上述现有技术中提出的取出重复消息的方案都是针对特定任务的,例 如针对 Map子任务的输出, 而在其他子任务不适用, 或设置没有提出任何解 决措施, 例如在 Cloud MapReduce技术中就没有提出解决 Reduce子任务输出 重复消息的问题的方案。  However, the solution for extracting duplicate messages proposed in the above prior art is specific to a specific task, for example, for the output of the Map subtask, but not applicable to other subtasks, or the setting does not propose any solution, such as in Cloud MapReduce technology. There is no proposal to solve the problem of the Reduce subtask outputting duplicate messages.
综上,现有技术中的分布式作业系统在实现业务处理的过程中, 并不存在 通用的去除重复消息的方法。 In summary, the distributed operating system in the prior art does not exist in the process of implementing business processing. A general method of removing duplicate messages.
发明内容 Summary of the invention
有鉴于此, 本发明实施例的目的在于提供分布式作业系统的业务处理方 法、执行单元和系统,适用于多任务处理过程中的任意任务中的重复消息去除 目的, 通用性好。  In view of this, an object of the embodiments of the present invention is to provide a service processing method, an execution unit, and a system for a distributed operating system, which are applicable to the purpose of removing duplicate messages in any task in the multitasking process, and have good versatility.
为实现上述目的,本发明实施例提供了一种分布式作业系统的业务处理方 法,在每个业务步骤中的执行单元针对从该业务步骤的输入队列中取出的每条 待处理消息执行如下操作:  To achieve the above objective, an embodiment of the present invention provides a service processing method for a distributed operating system, where an execution unit in each service step performs the following operations for each pending message retrieved from an input queue of the service step. :
当前执行单元针对从输入队列中所获取的一条待处理消息,运行该执行单 元所在业务步骤的业务处理程序, 产生至少一条业务处理结果消息;  The current execution unit runs a service processing program of the service step where the execution unit is located for a message to be processed obtained from the input queue, and generates at least one service processing result message;
所述当前执行单元将产生的业务处理结果消息存入该当前执行单元对应 的临时队列中;  The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit;
判断是否还没有其他执行单元将处理该条待处理消息所输出的业务处理 结果消息存入所述其他执行单元对应的临时队列中,如果没有, 则将所述当前 执行单元对应的临时队列作为当前临时队列,并且当前执行单元将所述当前临 时队列中的业务处理结果消息全部转移至输出队列中,至此该条待处理消息被 当前执行单元完全处理完毕,如果有, 则判断所述待处理消息是否已经被其他 执行单元完全处理完毕,对于未完全处理完毕的情况,将所述其他执行单元的 临时队列中、已经存入对该条待处理消息处理所得的业务处理结果消息的临时 队列作为当前临时队列。  Determining whether there is no other execution unit to store the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, the temporary queue corresponding to the current execution unit is used as the current a temporary queue, and the current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, so that the to-be-processed message is completely processed by the current execution unit, and if so, the pending message is determined. Whether it has been completely processed by other execution units. For the case where the processing is not completely processed, the temporary queue of the other execution unit that has been stored in the temporary processing queue for processing the processed message is processed as the current Temporary queue.
另一方面, 本发明还提供一种分布式作业系统的执行单元, 该执行单元用 于在其所在的业务步骤中针对从输入队列中取出的每条待处理消息进行处理, 该执行单元包括:  In another aspect, the present invention further provides an execution unit of a distributed operating system, configured to process, in a service step in which it is located, each pending message retrieved from an input queue, the execution unit comprising:
业务处理单元, 用于针对从输入队列中所获取的一条待处理消息,运行该 执行单元所在的业务步骤的业务处理程序, 产生至少一条业务处理结果消息; 处理结果保存单元,用于将产生的业务处理结果消息存入该执行单元对应 的临时队列中; 第一处理结果存入判断单元,用于判断是否还没有其他执行单元将处理该 条待处理消息所输出的业务处理结果消息存入所述其他执行单元对应的临时 队列中, 如果没有, 则将所述当前执行单元对应的临时队列作为当前队列, 如 果有, 则触发处理完毕判断单元工作; a service processing unit, configured to: for a pending message obtained from the input queue, run a service processing program of the service step where the execution unit is located, generate at least one service processing result message; and process a result saving unit, which is to be generated The service processing result message is stored in a temporary queue corresponding to the execution unit; The first processing result is stored in the judging unit, and is configured to determine whether the other execution unit has stored the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, if not, The temporary queue corresponding to the current execution unit is used as the current queue, and if so, the processing completion judgment unit is triggered to work;
处理完毕判断单元,用于判断所述待处理消息是否被其他执行单元完全处 理完毕, 对于未完全处理完毕的情况, 将所述其他执行单元的临时队列中、 已 经存入对该条待处理消息处理所得的业务处理结果消息的临时队列作为当前 临时队列;  The processing completion judging unit is configured to determine whether the to-be-processed message is completely processed by other execution units, and if the incomplete processing is completed, the pending queue of the other execution unit is already stored in the pending message. The temporary queue for processing the obtained service processing result message is used as the current temporary queue;
处理结果转移单元,用于将当前临时队列中的业务处理结果消息全部转移 至输出队列中, 至此该条待处理消息被完全处理完毕。  The processing result transfer unit is configured to transfer all the service processing result messages in the current temporary queue to the output queue, and the pending message is completely processed.
本发明另一方面还提供一种分布式作业系统,包括多个上述的执行单元和 存储消息记录表的存储单元。  Another aspect of the present invention also provides a distributed operating system comprising a plurality of the above-described execution units and a storage unit storing a message record table.
由此可见, 本发明实施例中,在每个执行单元将针对一个待处理消息进行 处理得到的业务处理结果消息转移至输出队列之前,都要判断是否还没有其他 执行单元将处理该条待处理消息所得的业务处理结果消息存入了对应的临时 队列中, 只有判断结果为没有的情况, 当前的执行单元才会将其所输出的业务 处理结果消息转移至输出队列中, 否则, 当前执行单元会将之前由其他执行单 元已经处理得到的业务处理结果消息转移至输出队列中。这样可以保证对于输 入队列中的同一待处理消息,只有一个执行单元处理输出的业务处理结果消息 最终会送入输出队列中,避免针对同一个待处理消息, 向输出队列中输出重复 的业务处理结果消息。并且该方案能够适用分布式业务系统的各个业务步骤的 方案, 因此其通用性更强。  It can be seen that, in the embodiment of the present invention, before each execution unit transfers the service processing result message processed for one to-be-processed message to the output queue, it is determined whether there is no other execution unit that will process the pending item. The service processing result message obtained by the message is stored in the corresponding temporary queue. If the judgment result is not, the current execution unit will transfer the service processing result message outputted by the current execution unit to the output queue. Otherwise, the current execution unit The business process result message that was previously processed by other execution units is transferred to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the service processing result message and finally sends it to the output queue, avoiding outputting duplicate service processing results to the output queue for the same pending message. Message. And the solution can be applied to the various business steps of the distributed business system, so it is more versatile.
附图说明 DRAWINGS
图 1是本发明实施例一提供的分布式作业系统的业务处理方法的流程图; 图 2是本发明实施例二提供的分布式作业系统的业务处理方法的流程图; 图 3是本发明实施例三中的方案应用场景示意图;  1 is a flowchart of a service processing method of a distributed operating system according to Embodiment 1 of the present invention; FIG. 2 is a flowchart of a service processing method of a distributed operating system according to Embodiment 2 of the present invention; A schematic diagram of a scenario application scenario in Example 3;
图 4是本发明实施例三中第 N个业务步骤的执行单元的处理过程示意图; 图 5是本发明实施例三提供的分布式作业系统的业务处理方法的流程图; 图 6是本发明实施例提供的分布式作业系统的业务处理方法的一种应用 举例示意图; 4 is a schematic diagram of a processing procedure of an execution unit of an Nth service step in Embodiment 3 of the present invention; FIG. 5 is a flowchart of a service processing method of a distributed operating system according to Embodiment 3 of the present invention; 6 is a schematic diagram of an application example of a service processing method of a distributed operating system according to an embodiment of the present invention;
图 Ί 是本发明实施例提供的分布式作业系统的业务处理方法的另一种应 用举例示意图;  Figure Ί is a schematic diagram of another application example of the service processing method of the distributed operating system provided by the embodiment of the present invention;
图 8 是本发明实施例提供的分布式作业系统的业务处理方法的另一种应 用举例示意图;  FIG. 8 is a schematic diagram of another application example of a service processing method of a distributed operation system according to an embodiment of the present invention; FIG.
图 9是本发明实施例提供的分布式作业系统的业务处理方法的另一种应 用举例示意图;  FIG. 9 is a schematic diagram of another application example of a service processing method of a distributed operating system according to an embodiment of the present invention; FIG.
图 10是本发明一个实施例提供的分布式作业系统的执行单元的示意图; 图 11 是本发明另一个实施例提供的分布式作业系统的执行单元的示意 图。  FIG. 10 is a schematic diagram of an execution unit of a distributed operating system according to an embodiment of the present invention; FIG. 11 is a schematic diagram of an execution unit of a distributed operating system according to another embodiment of the present invention.
具体实施方式 实施例一 DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
本发明实施例一提供一种分布式作业系统的业务处理方法, 如图 1所示, 该方法中,在每个业务步骤中的执行单元针对从该业务步骤的输入队列中取出 的每条待处理消息执行如下操作:  A first embodiment of the present invention provides a service processing method for a distributed operating system. As shown in FIG. 1, in the method, an execution unit in each service step is for each item to be taken from an input queue of the service step. Processing the message performs the following operations:
步骤 S101 : 当前执行单元针对从输入队列中所获取的一条待处理消息, 运行该执行单元所在业务步骤的业务处理程序,产生至少一条业务处理结果消 息。  Step S101: The current execution unit runs at least one service processing result message for the service processing program of the service step where the execution unit is located, for a message to be processed obtained from the input queue.
步骤 S102: 当前执行单元将产生的业务处理结果消息存入该当前执行单 元对应的临时队列中;  Step S102: The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit.
步骤 S103: 判断是否还有其他执行单元将处理该条待处理消息所输出的 业务处理结果消息存入所述其他执行单元对应的临时队列中,如果没有, 则将 当前执行单元对应的临时队列作为当前临时队列, 并执行步骤 S105; 如果有, 则执行步骤 104。  Step S103: determining whether there are other execution units storing the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, using the temporary queue corresponding to the current execution unit as The current temporary queue is executed, and step S105 is performed; if yes, step 104 is performed.
步骤 S104: 判断上述待处理消息是否已经被其他执行单元完全处理完毕, 对于未完全处理完毕的情况,将其他执行单元的临时队列中、 已经存入对该条 待处理消息处理所得的业务处理结果消息的临时队列作为当前临时队列,然后 执行步骤 S105。 Step S104: It is determined whether the to-be-processed message has been completely processed by other execution units. For the case that the processing is not completely processed, the service processing result of processing the pending message in the temporary queue of the other execution unit is already stored. The temporary queue of the message acts as the current temporary queue, then Step S105 is performed.
步骤 S105: 当前执行单元将当前临时队列中的业务处理结果消息全部转 移至输出队列中, 至此该条待处理消息被当前执行单元完全处理完毕。  Step S105: The current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed by the current execution unit.
由此可见, 本发明实施例提供的方法中,在每个执行单元将针对一个待处 理消息进行处理得到的业务处理结果消息转移至输出队列之前,都要判断是否 还没有其他执行单元将处理该条待处理消息所得的业务处理结果消息存入了 对应的临时队列中, 只有判断结果为没有的情况, 当前的执行单元才会将其所 输出的业务处理结果消息转移至输出队列中, 否则, 当前执行单元会将之前由 其他执行单元已经处理得到的业务处理结果消息转移至输出队列中。这样可以 保证对于输入队列中的同一待处理消息,只有一个执行单元处理输出的业务处 理结果消息最终会送入输出队列中,避免针对同一个待处理消息, 向输出队列 中输出重复的业务处理结果消息。  It can be seen that, in the method provided by the embodiment of the present invention, before each execution unit transfers the service processing result message processed for one to-be-processed message to the output queue, it is determined whether no other execution unit will process the The service processing result message obtained by the message to be processed is stored in the corresponding temporary queue. If the judgment result is not, the current execution unit will transfer the service processing result message outputted by the current execution unit to the output queue. Otherwise, The current execution unit transfers the business process result message that was previously processed by other execution units to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the service processing result message and finally sends it to the output queue, avoiding outputting duplicate service processing results to the output queue for the same pending message. Message.
需要说明的是,本发明实施例提供的方法是一种能够适用分布式业务系统 的各个业务步骤的方案, 因此其通用性更强。  It should be noted that the method provided by the embodiment of the present invention is a solution that can be applied to various service steps of a distributed service system, and therefore is more versatile.
实施例二  Embodiment 2
在实施例一的方案中, 虽然保证了针对同一个待处理消息, 不会向输出队 列中输出重复的业务处理结果消息,但是也可能会出现这样的情况: 在一个业 务步骤中, 一个执行单元 A在针对一条待处理消息执行步骤 S101中的业务处 理程序之前, 可能已经有其他执行单元(例如执行单元 B )对该待处理消息执 行了相同的业务处理程序,并已经将所输出的业务处理结果消息存入对应的临 时队列中, 但是由于执行单元 A在执行到步骤 S103时才会判断出执行单元 B 已经处理过该消息, 并已经将输出的消息存入执行单元 B 的临时队列中, 所 以执行单元 A仍然会执行步骤 S101和步骤 S102对同一待处理消息执行业务 处理程序, 这实际上也造成了处理资源的浪费。  In the solution of the first embodiment, although it is guaranteed that the duplicate service processing result message is not output to the output queue for the same pending message, it may happen that: in one service step, one execution unit A. Before executing the service processing program in step S101 for a message to be processed, there may already be other execution units (for example, execution unit B) executing the same business processing program for the message to be processed, and the processed business has been processed. The result message is stored in the corresponding temporary queue, but since the execution unit A determines that the execution unit B has processed the message when executing to step S103, and has already stored the output message in the temporary queue of the execution unit B, Therefore, the execution unit A still performs step S101 and step S102 to execute the business processing program on the same pending message, which actually causes waste of processing resources.
为了避免实施例一中的方法可能导致的上述处理资源浪费,在本发明实施 例二中提出一种优化的方案, 如图 2所示, 该方法中, 每个业务步骤中的执行 单元从该业务步骤的输入队列中取出每条待处理消息执行如下操作:  In order to avoid the waste of the foregoing processing resources that may be caused by the method in the first embodiment, an optimized solution is proposed in the second embodiment of the present invention. As shown in FIG. 2, in the method, the execution unit in each service step is from the The following steps are taken to retrieve each pending message from the input queue of the business step:
步骤 S201 : 判断是否还没有其他执行单元将处理当前执行单元所获取的 待处理消息而输出的业务处理结果存入该其他执行单元对应的临时队列中,如 果没有, 则执行步骤 202; 如果有, 则执行步骤 S205。 Step S201: determining whether there is no other execution unit to store the service processing result outputted by the current execution unit to be processed into the temporary queue corresponding to the other execution unit, such as If not, step 202 is performed; if yes, step S205 is performed.
步骤 S202: 当前执行单元针对所获取的待处理消息, 运行该执行单元所 在业务步骤的业务处理程序, 产生至少一条业务处理结果消息;  Step S202: The current execution unit runs a service processing procedure of the service step of the execution unit for the acquired to-be-processed message, and generates at least one service processing result message.
步骤 S203: 当前执行单元将产生的业务处理结果消息存入该当前执行单 元对应的临时队列中;  Step S203: The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit.
步骤 S204: 判断是否还有其他执行单元将处理该条待处理消息所输出的 业务处理结果消息存入所述其他执行单元对应的临时队列中,如果没有, 则将 当前执行单元对应的临时队列作为当前临时队列, 并执行步骤 S206; 如果有, 则执行步骤 205。  Step S204: determining whether there are other execution units storing the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, using the temporary queue corresponding to the current execution unit as The current temporary queue is executed, and step S206 is performed; if yes, step 205 is performed.
步骤 S205: 判断上述待处理消息是否已经被其他执行单元完全处理完毕, 对于未完全处理完毕的情况,将其他执行单元的临时队列中、 已经存入对该条 待处理消息处理所得的业务处理结果消息的临时队列作为当前临时队列,然后 执行步骤 S206。  Step S205: It is determined whether the to-be-processed message has been completely processed by other execution units. For the case that the processing is not completely processed, the service processing result of processing the pending message in the temporary queue of the other execution unit is already stored. The temporary queue of the message is used as the current temporary queue, and then step S206 is performed.
步骤 S206: 当前执行单元将当前临时队列中的业务处理结果消息全部转 移至输出队列中, 至此该条待处理消息被当前执行单元完全处理完毕。  Step S206: The current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed by the current execution unit.
由此可见, 本实施例提供的方法除了能够避免针对同一个待处理消息, 向 输出队列中输出重复的业务处理结果消息,还在当前执行单元对一条待处理消 息执行业务处理程序之前,判断是否还没有其他执行单元将处理该条待处理消 息所输出的业务处理结果消息存入所述其他执行单元对应的临时队列中,只有 判断结果为没有的情况, 当前执行单元才会对该条待处理消息进行处理,避免 处理资源的浪费。 实施例三  Therefore, the method provided in this embodiment can not only output a repeated service processing result message to the output queue for the same pending message, but also determine whether the current execution unit performs a service processing procedure on a to-be-processed message. There is no other execution unit that stores the service processing result message outputted by the processing of the to-be-processed message in the temporary queue corresponding to the other execution unit. If the judgment result is not, the current execution unit will process the item to be processed. Messages are processed to avoid wasting processing resources. Embodiment 3
本例中以一个具体的应用场景详细说明本发明方案的实现。  In this example, the implementation of the solution of the present invention is described in detail in a specific application scenario.
在本实施例方案所应用的分布式作业系统中,如图 3所示, 整个业务模型 由多个业务步骤(step )组成, 业务步骤之间的关系串接的, 如图 3所示, 每 个业务步骤都包含输入队列、 执行单元、 输出队列, 并使用消息记录表来记录 消息的处理过程。  In the distributed operating system to which the solution in this embodiment is applied, as shown in FIG. 3, the entire service model is composed of multiple service steps (steps), and the relationships between the business steps are concatenated, as shown in FIG. Each business step consists of an input queue, an execution unit, an output queue, and a message log table to record the processing of the message.
而图 3中的 StepN队列是指第 N个业务步骤的执行单元的输入队列, 提 供待处理的消息, 它同时也是第 N-1个业务步骤的执行单元的输出队列,用于 收集和传输产生的新消息。 The StepN queue in Figure 3 refers to the input queue of the execution unit of the Nth business step. For the message to be processed, it is also the output queue of the execution unit of the N-1th business step for collecting and transmitting the generated new message.
每个业务步骤的执行单元是该业务中的最小执行单元,每个业务步骤都可 以有多个执行单元。执行单元从输入队列中获取消息,运行业务程序处理该消 息, 并将产生的消息放入输出队列中。  The execution unit of each business step is the smallest execution unit in the business, and each business step can have multiple execution units. The execution unit gets the message from the input queue, runs the business program to process the message, and puts the generated message into the output queue.
消息记录表可以存储在 SDB中, SDB可以是一个可大规模伸缩和高可用 性的非关系型数据存储数据库。在本发明实施例中,对数据的结构有特别的设 计,例如:每一行数据为一个条目( item ),每个条目可以有多个属性( attribute ), 每个属性可以有多个值( value )。  The message record table can be stored in the SDB, which can be a non-relational data storage database that can be scaled and highly available. In the embodiment of the present invention, the structure of the data is specially designed. For example, each row of data is an item, each entry may have multiple attributes, and each attribute may have multiple values (value ).
在本发明实施例的消息记录表中, 每个待处理消息的消息 ID ( MsgID ) 作为一个条目,每个条目中的属性包括接收时间( ReceiveTime )、执行单元 ID ( WorkerlD ), 提交时间 ( CommitTime )、 临时队列地址 ( TempQueueURL ) 和完成时间 ( FinishTime )。  In the message record table of the embodiment of the present invention, the message ID (MsgID) of each to-be-processed message is taken as an entry, and the attributes in each entry include the receiving time (ReceiveTime), the execution unit ID (WorkerDD), and the commit time (CommitTime). ), temporary queue address ( TempQueueURL ) and completion time ( FinishTime ).
在每个执行单元中处理一个消息的时候,都会创建一个临时队列, 消息处 理过程中产生的所有新消息都被放入这个临时队列中,同时临时队列的地址被 写入消息记录表中与该新消息相对应的条目的 "临时队列地址" 属性中。  When processing a message in each execution unit, a temporary queue is created. All new messages generated during message processing are placed in the temporary queue, and the address of the temporary queue is written in the message record table. The new message corresponds to the entry in the "temporary queue address" attribute.
在本发明中对于消息记录表的写入条件做了特别的限定,将在后面的各个 步骤详细说明。  The writing conditions of the message recording table are specifically limited in the present invention, and will be described in detail in the subsequent steps.
图 4中示出了第 N个业务步骤的执行单元的处理过程示意图, 可见第 N 个业务步骤的执行单元从第 N-1个业务步骤的执行单元输出的队列(也是第 N 个业务步骤的执行单元的输入队列) 中获取消息 (图 4中的第 1步), 并在消 息记录表中针对该获取的消息写入消息 获取记录(图 4中的第 2步); 当第 N 个业务步骤的执行单元在第 3步中将该消息处理完毕后,将产生的新消息放入 该执行单元的临时队列中, 并在第 4步中写入消息处理记录; 然后第 N个业 务步骤的执行单元将临时队列中的消息转移到输出队列中(图 4中的第 5步), 并在消息记录表中写入完成记录(图 4中的第 6步)。 需要说明的是, 图 4中 所示的是第 N个业务步骤的一个执行单元在写入步骤均正常完成的情况下的 执行情况,而实际上本发明实施例提供的方法的步骤中还要考虑写入的条件限 制, 以实现防止重复消息输出的问题, 以下详细说明。 参见图 5 , 本实施例提供的分布式作业系统的业务处理方法包括如下步 骤: FIG. 4 is a schematic diagram showing the processing procedure of the execution unit of the Nth service step, and it can be seen that the execution unit of the Nth service step outputs the queue from the execution unit of the N-1th business step (also the Nth business step). Obtaining a message in the input queue of the execution unit (step 1 in Fig. 4), and writing a message acquisition record for the acquired message in the message record table (step 2 in Fig. 4); when the Nth service After the processing unit of the step finishes processing the message in the third step, the generated new message is placed in the temporary queue of the execution unit, and the message processing record is written in the fourth step; then the Nth business step is The execution unit transfers the message in the temporary queue to the output queue (step 5 in Figure 4) and writes the completion record in the message record table (step 6 in Figure 4). It should be noted that, in FIG. 4, the execution of an execution unit of the Nth service step in the case that the writing step is normally completed, in fact, in the steps of the method provided by the embodiment of the present invention, Consider the conditional constraints of writing to achieve the problem of preventing duplicate message output, as detailed below. Referring to FIG. 5, the service processing method of the distributed operating system provided by this embodiment includes the following steps:
步骤 S501 : 执行单元从输入队列中获取一条消息, 作为当前处理的消息; 在本实施例中, 该执行单元并不限定是在某一个特定业务步骤的执行单 元。 当该执行单元是第二个业务步骤及以后步骤的执行单元时, 该输入队列是 该执行单元所在的业务步骤的上一业务步骤输出的消息形成的队列;当该执行 单元是第一个业务步骤的执行单元时,则该输入队列就是系统最初接收到的消 息形成的队列。  Step S501: The execution unit acquires a message from the input queue as the currently processed message. In this embodiment, the execution unit is not limited to an execution unit at a specific service step. When the execution unit is the execution unit of the second service step and the subsequent step, the input queue is a queue formed by the message output by the previous service step of the service step where the execution unit is located; when the execution unit is the first service When the execution unit of the step, the input queue is the queue formed by the message originally received by the system.
步骤 S502: 上述执行单元向消息记录表中以该获取的待处理消息的 ID开 始, 写入消息获取记录, 写入的过程包括: 向该获取的消息的 ID对应的条目 ( Item ) 中的 "接收时间" 属性加入该执行单元获取该消息的时间, 向同一条 目中的 "执行单元 ID" 属性中加入该执行单元的 ID。  Step S502: The execution unit starts to write a message acquisition record to the message record table by using the acquired ID of the to-be-processed message, and the process of writing includes: to the item corresponding to the ID of the acquired message (Item) The receiving time " attribute joins the execution unit to get the message, and adds the ID of the execution unit to the "execution unit ID" attribute in the same entry.
步骤 S503: 判断步骤 S502中写入的条目中的 "提交时间"属性的值是否 为空, 如果是, 则执行单元在步骤 S502中的写入成功, 继续执行步骤 S504; 否则,则表示执行单元在步骤 S502中的写入失败,清除步骤 S502中写入的数 据, 之后执行步骤 510。  Step S503: determining whether the value of the "commit time" attribute in the entry written in step S502 is empty, if yes, the execution unit succeeds in step S502, and proceeds to step S504; otherwise, indicates the execution unit The writing in step S502 fails, the data written in step S502 is cleared, and then step 510 is performed.
在本实施方式中, 判断写入的条目中的 "提交时间"属性的值是否为空实 际上就是在判断该条目中是否已经写入了消息处理记录。  In the present embodiment, it is judged whether or not the value of the "commit time" attribute in the written entry is empty. Actually, it is judged whether or not the message processing record has been written in the entry.
步骤 S504: 当步骤 S503中确认写入成功后, 该执行单元运行业务程序处 理获取到的待处理消息,并把处理过程中产生的新消息(即业务处理结果消息 ) 存入到该执行单元的临时队列中。  Step S504: After confirming that the writing is successful in step S503, the executing unit runs the business program to process the acquired pending message, and stores the new message generated during the processing (ie, the business processing result message) into the execution unit. In the temporary queue.
实际上, 由于一个条目中的 "提交时间"是在该条目对应的消息已经被某 一个执行单元处理完、并将业务处理结果消息存储入到临时队列中时, 才会加 入的,因此当步骤 S503中确认写入成功时,表明该获取的消息的条目中的 "提 交时间"属性的值为空, 进一步表示该待处理消息还未成功被其他执行单元处 理完毕并将业务处理结果消息存储入到临时队列,所以本执行单元继续处理该 获取到的消息才有意义, 可以进一步节省处理资源。  In fact, since the "commit time" in an entry is that the message corresponding to the entry has been processed by an execution unit and the business process result message is stored in the temporary queue, it is added, so when the step When it is confirmed in S503 that the writing is successful, it indicates that the value of the "commit time" attribute in the entry of the acquired message is null, further indicating that the pending message has not been successfully processed by other execution units and the business processing result message is stored. It is meaningful to the temporary queue, so the execution unit continues to process the obtained message, which can further save processing resources.
步骤 S505:以该待处理的消息的 ID写入消息处理记录,写入的过程包括: 开始向该待处理消息的 ID对应的条目中的 "提交时间" 和 "临时队列地址" 两个属性中, 分别加入步骤 S504中把产生的业务处理消息存入到临时队列的 时间和该临时队列的地址。 Step S505: Writing a message processing record with the ID of the message to be processed, the process of writing includes: starting a "commit time" and a "temporary queue address" in an entry corresponding to the ID of the to-be-processed message. The two attributes are respectively added to the time when the generated service processing message is stored in the temporary queue in step S504 and the address of the temporary queue.
步骤 S506: 判断步骤 S505中写入的条目中的 "提交时间"属性的值是否 为空, 如果是, 则执行单元在步骤 S505中的写入成功, 则将步骤 S505中写入 的临时队列地址作为当前临时队列地址, 继续执行步骤 S507; 否则写入失败, 并清除步骤 S505中写入的数据, 之后执行步骤 S510。  Step S506: It is judged whether the value of the "commit time" attribute in the entry written in step S505 is empty. If yes, the execution unit succeeds in the writing in step S505, and the temporary queue address written in step S505 is obtained. As the current temporary queue address, step S507 is continued; otherwise, the write fails, and the data written in step S505 is cleared, and then step S510 is performed.
实际上, 对于当步骤 S503中已经判断获取消息记录写入成功, 但后续的 步骤 S506 中还要依据相类似的提交来判断处理消息是否写入成功的原因在 于: 在某个执行单元在步骤 S502中成功写入获取消息记录时, 还没有其他执 行单元已经处理完该获取的消息, 即步骤 S503中当时会判断写入成功, 但是 随着该执行单元对该获取的消息进行处理的过程中,可能有其他的执行单元将 该获取的同一消息处理完毕并存入到了临时队列,从而更新了消息记录表中关 于该消息的条目, 使得其中的 "提交时间" 和 "临时队列地址" 的属性均不再 为空, 如果在后续的步骤 S506中不再依据同一写入限制条件进行判断, 则会 造成重复处理以及最终输出重复的新消息。  In fact, for the reason that it is determined in step S503 that the acquisition message record is successfully written, but the subsequent step S506 is still based on the similar submission to determine whether the processing message is successfully written, the reason is: at a certain execution unit in step S502 When the message record is successfully written in the acquisition, no other execution unit has processed the acquired message, that is, the process is judged to be successful in step S503, but in the process of processing the acquired message by the execution unit, There may be other execution units that process the acquired same message and store it in the temporary queue, thereby updating the entry in the message record table about the message, so that the attributes of "commit time" and "temporary queue address" are both It is no longer empty. If it is no longer judged according to the same write restriction condition in the subsequent step S506, it will cause repeated processing and finally output a new message that is repeated.
步骤 S507: 根据当前临时队列地址, 从对应的临时队列中获取消息 (即 获取各条业务处理结果消息), 并放入输出队列中, 直到该临时队列取空。  Step S507: Obtain a message from the corresponding temporary queue according to the current temporary queue address (that is, obtain each service processing result message), and put it into the output queue until the temporary queue is emptied.
步骤 S508: 向消息记录表中针对上述待处理消息的消息 ID对应的条目, 写入该条目中写入完成记录, 具体包括: 将全部转移完当前临时队列中的业务 处理消息至输出队列中的时间写入该条目中的 "完成时间" 属性中。  Step S508: Write the write completion record in the entry to the entry corresponding to the message ID of the to-be-processed message in the message record table, and specifically include: transferring all the service processing messages in the current temporary queue to the output queue The time is written to the "Completion Time" attribute in the entry.
步骤 S509: 从输入队列中删除当前处理的消息, 回到步骤 S501。  Step S509: The currently processed message is deleted from the input queue, and the process returns to step S501.
步骤 S510: 当步骤 S503或者步骤 S506中的判断结果为否时, 从消息记 录表中获取当前待处理的消息的条目中的所有属性的值。  Step S510: When the result of the determination in step S503 or step S506 is no, the value of all the attributes in the entry of the current message to be processed is obtained from the message record table.
实际上, 当一个执行单元执行步骤 S510时, 意味着其他执行单元已经将 输入队列中的同一消息处理完,但是否已经完全将生成的新消息放入输出队列 还要靠后面的判断步骤确定。  In fact, when an execution unit executes step S510, it means that the other execution units have processed the same message in the input queue, but whether the generated new message has been completely put into the output queue is determined by the subsequent judgment step.
步骤 S511 : 判断步骤 S510中获得的属性中 "完成时间"属性的值是否为 空, 如果否, 则返回执行步骤 S501 ; 如果是, 则继续执行步骤 S512。  Step S511: It is judged whether the value of the "Completion Time" attribute in the attribute obtained in step S510 is empty, and if not, the process returns to step S501; if yes, the process proceeds to step S512.
步骤 S512: 将当前待处理的消息的条目中的 "临时队列地址" 属性的值 作为当前的临时队列地址, 然后返回执行步骤 S507。 Step S512: The value of the "temporary queue address" attribute in the entry of the current pending message As the current temporary queue address, then return to step S507.
实际上, 对于步骤 S511 中判断结果为否, 则表明同一待处理消息已经被 其他执行单元完全处理完毕,并已经将生成的业务处理结果消息输出到输出队 列中, 因此本执行单元不应该再对本消息进行后续的处理, 而应该重新从输入 队列中取出下一条消息, 即返回执行步骤 S501。  In fact, if the result of the determination in step S511 is NO, it indicates that the same pending message has been completely processed by other execution units, and the generated service processing result message has been output to the output queue, so the execution unit should not re-book this The message is subsequently processed, and the next message should be retrieved from the input queue again, that is, the process returns to step S501.
对于步骤 S511中判断结果为是, 则表明其他执行单元已经对输入队列中 的同一消息处理完成,并且将处理后输出的新消息已经写入到该其他执行单元 的临时队列中, 并且还写入了消息处理记录。 此时根据步骤 S512当前的执行 单元会调出之前写入消息处理记录的执行单元的临时队列地址,并从该临时队 列的地址作为当前临时队列的地址, 进而通过执行步骤 S507将该临时队列中 已经输出的新消息放入到本业务步骤的输出队列中,进而防止多个执行单元重 复输出相同的新消息。 在以上结合图 5 对本发明实施例中每个业务步骤中的以某个执行单元的 角度描述本发明的各个步骤的基石出之上,以下详细说明多个执行单元情况的具 体适用。  If the result of the determination in step S511 is YES, it indicates that the other execution units have finished processing the same message in the input queue, and the new message outputted after the processing has been written into the temporary queue of the other execution unit, and is also written. The message processing record. At this time, according to step S512, the current execution unit calls up the temporary queue address of the execution unit that previously wrote the message processing record, and the address of the temporary queue is used as the address of the current temporary queue, and then proceeds to the temporary queue by performing step S507. The new message that has been output is placed in the output queue of this business step, thereby preventing multiple execution units from repeatedly outputting the same new message. The above is the basis of describing the steps of the present invention in terms of a certain execution unit in each of the business steps in the embodiment of the present invention with reference to Fig. 5, and the specific application of the plurality of execution unit cases will be described in detail below.
图 6示出的为在第 N个业务步骤中仅仅有一个执行单元从输入队列中获 取某个消息的整个处理过程。 如图 6所示, 该过程具体包括:  Figure 6 shows the entire process of obtaining a message from an input queue with only one execution unit in the Nth business step. As shown in FIG. 6, the process specifically includes:
步骤 S601: 执行单元从输入队列中获取一条待处理消息。  Step S601: The execution unit acquires a pending message from the input queue.
步骤 S602: 执行单元向消息记录表中该待处理消息写入消息获取记录, 由于该消息是本执行单元第一次从输入队列中获取的,因此在消息记录表中可 能还没有该消息的任何条目, 所以在本步骤中, 会为该获取到的消息创建新的 条目, 并填入消息获取记录中包含的接收时间和执行单元 ID两个属性的值。  Step S602: The execution unit writes a message acquisition record to the to-be-processed message in the message record table. Since the message is obtained by the execution unit from the input queue for the first time, there may not be any message in the message record table. An entry, so in this step, a new entry is created for the acquired message, and the values of the two attributes of the receiving time and the execution unit ID contained in the message acquisition record are filled in.
步骤 S603: 由于之前没有其他的执行单元获取该消息, 因此在消息记录 表中,该消息对应的条目的提交时间属性的值为空,所以消息记录表写入成功, 并通知执行单元。  Step S603: Since no other execution unit acquires the message before, in the message record table, the value of the submission time attribute of the entry corresponding to the message is null, so the message record table is successfully written, and the execution unit is notified.
步骤 S604: 该执行单元针对该条获取到待处理消息运行业务步骤的业务 处理程序, 并将输出的新消息存入临时队列中。  Step S604: The execution unit acquires a business processing program of the business step of the message to be processed for the strip, and stores the output new message in the temporary queue.
步骤 S605: 该执行单元开始向消息记录表中针对该待处理消息的条目, 写入消息处理记录, 包括写入提交时间和存放输出消息的临时队列地址。 Step S605: The execution unit starts to input an entry for the to-be-processed message in the message record table. Writes a message processing record, including the write commit time and the temporary queue address where the output message is stored.
步骤 S606: 判定步骤 S605中写入消息处理记录写入成功, 并通知该执行 单元。  Step S606: It is determined in step S605 that the write message processing record is successfully written, and the execution unit is notified.
步骤 S607: 执行单元将临时队列中的消息全部移到输出队列中。  Step S607: The execution unit moves all the messages in the temporary queue to the output queue.
步骤 S608: 执行单元项消息记录表中针对所述待处理的消息对应的条目 写入消息完成记录, 即在该条目中加入完成时间属性的值。  Step S608: In the execution unit item message record table, the message completion record is written for the entry corresponding to the to-be-processed message, that is, the value of the completion time attribute is added to the entry.
步骤 S609: 判定写入消息完成记录写入成功, 并通知该执行单元。  Step S609: It is determined that the write message completion record is successfully written, and the execution unit is notified.
步骤 S610: 执行单元从输入队列中删除前面已经处理完成的消息。 图 7示出的是在第 N个业务步骤中多个执行单元从输入队列中获取了同 一个消息的整个处理过程。 由于 SQS机制的特性, 多个从同一个输入队列获 取消息的执行单元可能会获取同一个消息, 并且在 SQS机制中, 允许多个执 行单元同时处理同一个消息,在本发明中产生的新消息都先放入到各自的临时 队列中,但是通过图 5中阐释的条件写入机制, 只有一个执行单元的处理该消 息所得的输出消息会被放入输出队列,保证不会有重复的处理结果放入输出队 列中。  Step S610: The execution unit deletes the previously processed message from the input queue. Figure 7 shows the overall processing of multiple execution units getting the same message from the input queue in the Nth business step. Due to the nature of the SQS mechanism, multiple execution units that acquire messages from the same input queue may acquire the same message, and in the SQS mechanism, allow multiple execution units to simultaneously process the same message, new messages generated in the present invention. They are all put into their respective temporary queues, but through the conditional write mechanism illustrated in Figure 5, only one execution unit's output message processed by the message will be placed in the output queue, ensuring that there will be no duplicate processing results. Put in the output queue.
如图 7所示, 该过程具体包括:  As shown in Figure 7, the process specifically includes:
步骤 S701: 执行单元 1从输入队列中获取消息 a。  Step S701: The execution unit 1 obtains the message a from the input queue.
步骤 S702: 执行单元 1向消息记录表中写入消息获取记录, 进而在消息 记录表中为该消息 a创建一个条目, 并在该条目中的 "接收时间 " 和 "执行单 元 ID"两个属性中分别加入执行单元 1获取消息 a的时间和执行单元 1的 ID, 经过消息获取记录写入条件 (即该消息 a的条目中的 "提交时间"属性的值为 空) 的判断, 确定写入成功。  Step S702: The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time" and "execution unit ID" in the entry. The time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time" attribute in the entry of the message a is empty), and the writing is determined. success.
步骤 S703: 之后, 执行单元 2从输入队列中获取同一消息 a。  Step S703: After that, the execution unit 2 acquires the same message a from the input queue.
步骤 S704: 执行单元 2也开始向消息记录表中写入消息获取记录, 即向 消息 a的条目的 "接收时间" 和 "执行单元 ID" 两个属性中分别加入执行单 元 2获取消息 a的时间和执行单元 2的 ID; 由于此时在消息记录表中, 消息 a 的条目中的 "提交时间"属性的值仍为空, 所以该执行单元 2的写入消息获取 记录的写入操作也满足写入条件, 确定写入成功。 因此, 此时消息 a的条目中的执行单元 ID属性的值就包括两个: 执行单 元 1的 ID和执行单元 2的 ID; 而该条目的 "接收时间" 属性的值也有两个: 执行单元 1获取消息 a的时间和执行单元 2获取消息 a的时间。 Step S704: The execution unit 2 also starts writing a message acquisition record to the message record table, that is, adding the time of the execution unit 2 to the message a to the two attributes of the "reception time" and the "execution unit ID" of the entry of the message a And the ID of the execution unit 2; since the value of the "commit time" attribute in the entry of the message a is still empty in the message record table at this time, the write operation of the write message acquisition record of the execution unit 2 is also satisfied. Write conditions to determine that the write was successful. Therefore, at this time, the value of the execution unit ID attribute in the entry of the message a includes two: the ID of the execution unit 1 and the ID of the execution unit 2; and the value of the "reception time" attribute of the entry also has two: execution unit 1 The time at which the message a is acquired and the time at which the execution unit 2 acquires the message a.
步骤 S705: 执行单元 1运行第 N个业务步骤的业务程序对其获取的消息 a进行处理, 产生新的消息存入到临时队列 1中。  Step S705: The service program running the Nth business step of the execution unit 1 processes the message a obtained, and generates a new message to be stored in the temporary queue 1.
步骤 S706: 执行单元 2也运行第 N个业务步骤的业务程序对其获取的消 息 a进行处理, 产生新的消息存入到临时队列 2中。  Step S706: The execution unit 2 also processes the message A of the Nth business step to process the message a obtained, and generates a new message to be stored in the temporary queue 2.
需要说明的是,由于本发明实施例提供的方法是分布式作业系统的业务处 理方法, 因此同一个业务步骤内的多个执行单元所运行的业务程序是一样的, 所以上述执行单元 1和执行单元 2处理相同的消息 a所输出的新消息也是相同 的 (消息数量、 内容和类型)。  It should be noted that, since the method provided by the embodiment of the present invention is a service processing method of a distributed operation system, the service programs run by multiple execution units in the same service step are the same, so the execution unit 1 and the execution are performed. The new message output by unit 2 processing the same message a is also the same (number of messages, content and type).
步骤 S707: 由于执行单元 1先完成了对消息 a的处理, 因此执行单元 1 先向消息记录表中开始写入消息处理记录,即向消息记录表中与消息 a对应的 条目中的 "提交时间"加入执行单元 1将处理消息 a所得的新消息存入临时队 列 1的时间, 以及向 "临时队列地址"属性中加入执行单元 1存入输出的新消 息的临时队列 1的地址; 由于在执行单元 1针对消息 a写入消息处理记录时, 消息 a的条目中的 "提交时间"属性的值仍然为空, 所以满足写入条件, 确认 写入成功 (步骤 S708 )。  Step S707: Since the execution unit 1 completes the processing of the message a first, the execution unit 1 first starts writing the message processing record to the message record table, that is, the "submission time" in the entry corresponding to the message a in the message record table. "The time at which the join execution unit 1 stores the new message obtained by processing the message a into the temporary queue 1, and the address of the temporary queue 1 in which the new message of the execution unit 1 is stored in the "temporary queue address" attribute is added; When the unit 1 writes the message processing record for the message a, the value of the "commit time" attribute in the entry of the message a is still empty, so the writing condition is satisfied, and the writing is confirmed to be successful (step S708).
步骤 S709: 执行单元 1在确认消息处理记录写入成功后, 从临时队列 1 中获取消息, 并开始向输出队列中转移。  Step S709: After confirming that the message processing record is successfully written, the execution unit 1 acquires the message from the temporary queue 1 and starts to transfer to the output queue.
步骤 S710: 执行单元 2在执行单元 1还未完全将临时队列 1 中的消息全 部转移至输出队列中时, 向消息记录表中开始写入消息处理记录, 即向 SDB 中与消息 a对应的条目中的 "提交时间 "加入执行单元 2将处理消息 a所得的 新消息存入临时队列 2的时间, 以及向 "临时队列地址"属性中加入执行单元 2存入输出的新消息的临时队列 2的地址; 由于在执行单元 2针对消息 a写入 消息处理记录时, 消息 a的条目中的 "提交时间" 属性的值已经在步骤 S707 中加入了执行单元 1将所得的新消息存入临时队列 1的时间,所以本步骤中不 满足写入条件, 确认写入失败(步骤 S711 )。  Step S710: When the execution unit 1 has not completely transferred all the messages in the temporary queue 1 to the output queue, the execution unit 2 starts writing the message processing record to the message record table, that is, the entry corresponding to the message a in the SDB. The "commit time" in the joining execution unit 2 stores the new message obtained by processing the message a into the temporary queue 2, and adds the temporary queue 2 of the new message that the execution unit 2 stores the output to the "temporary queue address" attribute. Address; Since the message processing record is written to the message a at the execution unit 2, the value of the "commit time" attribute in the entry of the message a has been added to the execution unit 1 in step S707, and the resulting new message is stored in the temporary queue 1 Since the write condition is not satisfied in this step, the write failure is confirmed (step S711).
步骤 S712: 执行单元 2在收到针对消息 a的消息处理记录写入失败的通 知后, 从消息记录表中读取消息 a的条目中的各属性的值, 获取到 "临时队列 地址"属性的值, 并将该值所表示的临时队列 1的地址作为当前要操作的临时 队列地址。 Step S712: The execution unit 2 receives the failure of the message processing record write failure for the message a. After knowing, the value of each attribute in the entry of the message a is read from the message record table, the value of the "temporary queue address" attribute is obtained, and the address of the temporary queue 1 represented by the value is taken as the temporary to be operated. Queue address.
步骤 S713 : 执行单元 2根据临时队列 1的地址, 继续从临时队列 1 中获 取剩余的消息, 转移至输出队列中。  Step S713: The execution unit 2 continues to obtain the remaining messages from the temporary queue 1 according to the address of the temporary queue 1, and transfers to the output queue.
需要说明的是,在本实施例中, 允许多个执行单元对同一个临时队列中的 消息进行转移。  It should be noted that, in this embodiment, multiple execution units are allowed to transfer messages in the same temporary queue.
步骤 S714: 执行单元 1向消息记录表中针对消息 a的条目写入消息完成 记录, 并写入成功。  Step S714: The execution unit 1 writes a message completion record to the entry of the message record table for the message a, and the writing is successful.
步骤 S715: 执行单元 2向消息记录表中针对消息 a的条目写入消息完成 记录, 并写入成功。  Step S715: The execution unit 2 writes a message completion record to the entry of the message record table for the message a, and the writing is successful.
在本实施例中,只需要保证向输出队列中转移的消息只在一个临时队列中 即可, 对于消息完成记录不必要求唯一。  In this embodiment, it is only necessary to ensure that the message transferred to the output queue is only in one temporary queue, and the message completion record does not need to be unique.
步骤 S716: 执行单元 1从输入队列中删除消息 a。  Step S716: The execution unit 1 deletes the message a from the input queue.
步骤 S717: 执行单元 2从输入队列中删除消息 。  Step S717: Execution unit 2 deletes the message from the input queue.
在本实施例中, 如果步骤 S716 中已经成功将消息 a删除, 则步骤 S717 中的删除动作仍然会执行, 只是在实际删除时会发现消息 a已经不存在,但仍 然可以返回删除成功的结果。  In this embodiment, if the message a has been successfully deleted in step S716, the deletion action in step S717 is still performed, but only when the actual deletion is found, the message a does not exist, but the result of the successful deletion can still be returned.
由此可见, 尽管由于 SQS本身的机制, 多个执行单元会获取同一个消息 并输出相同的新消息, 进而分别存入不同的临时队列中,但只有一个临时队列 中的消息会被转移至输出队列中,因此不会产生针对同一个消息输出重复处理 结果的问题。 另外,执行单元难免也会发生故障,故障的发生一方面可能会造成所获取 的消息未被成功处理,也可能造成因为不合适的故障恢复方法导致输出重复消 息的问题。以下不妨分别以执行单元在消息处理过程中和在消息处理结束后发 生故障为例, 详细说明利用图 5中所阐释的条件写入机制的具体过程。  It can be seen that although due to the mechanism of SQS itself, multiple execution units will acquire the same message and output the same new message, and then store them in different temporary queues, but only one message in the temporary queue will be transferred to the output. In the queue, there is no problem with duplicate processing results for the same message output. In addition, the execution unit will inevitably fail, and the failure may cause the acquired message to be unsuccessfully processed, or may cause the output to repeat the message due to the inappropriate failure recovery method. In the following, the specific process of using the conditional write mechanism illustrated in FIG. 5 will be described in detail by taking the execution unit as a failure during the message processing and after the end of the message processing.
图 8示出的是本发明实施例中在第 N个业务步骤中的某个执行单元在消 息处理过程中发生故障后实现消息重新处理的流程图, 具体包括: 步骤 S801: 执行单元 1从输入队列中获取消息 a。 FIG. 8 is a flowchart of implementing message reprocessing after a certain execution unit in the Nth service step fails in the message processing process in the embodiment of the present invention, which specifically includes: Step S801: The execution unit 1 acquires the message a from the input queue.
步骤 S802: 执行单元 1向消息记录表中写入消息获取记录, 进而在消息 记录表中为该消息 a创建一个条目, 并在该条目中的 "接收时间 " 和 "执行单 元 ID"两个属性中分别加入执行单元 1获取消息 a的时间和执行单元 1的 ID, 经过消息获取记录写入条件 (即该消息 a的条目中的 "提交时间"属性的值为 空) 的判断, 确定写入成功。  Step S802: The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time" and "execution unit ID" in the entry. The time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time" attribute in the entry of the message a is empty), and the writing is determined. success.
步骤 S803: 执行单元 1开始运行第 N个业务步骤的业务程序对其获取的 消息 a进行处理, 并同时将产生新的消息存入到临时队列 1中。  Step S803: The execution unit 1 starts the business program running the Nth business step to process the message a obtained, and simultaneously stores the generated new message into the temporary queue 1.
步骤 S804: 执行单元 1在执行业务程序的过程中发生故障。  Step S804: The execution unit 1 fails during the execution of the business program.
步骤 S805: 执行单元 2从输入队列中获取同一消息 a。  Step S805: Execution unit 2 acquires the same message a from the input queue.
步骤 S806: 执行单元 2向也开始向消息记录表中写入消息获取记录, 即 向消息 a的条目的 "接收时间" 和 "执行单元 ID" 两个属性中分别加入执行 单元 2获取消息 a的时间和执行单元 2的 ID; 由于此时在消息记录表中, 消 息 a的条目中的 "提交时间"属性的值仍为空, 所以该执行单元 2的写入消息 获取记录的写入操作也满足写入条件, 确定写入成功。  Step S806: The execution unit 2 also starts to write a message acquisition record to the message record table, that is, adding the execution unit 2 to the two items of the "reception time" and the "execution unit ID" of the entry of the message a to obtain the message a. Time and ID of execution unit 2; since the value of the "commit time" attribute in the entry of the message a is still empty in the message record table at this time, the write operation of the write message acquisition record of the execution unit 2 is also The write condition is met and the write is determined to be successful.
步骤 S807: 执行单元 2也运行第 N个业务步骤的业务程序对其获取的消 息 a进行处理, 产生新的消息存入到临时队列 2中。  Step S807: The execution unit 2 also runs the business program of the Nth business step to process the message a obtained, and generates a new message to be stored in the temporary queue 2.
步骤 S808: 执行单元 2在处理完消息 a并将所产生的新消息全部存入到 临时队列 2中之后, 向消息记录表中开始写入消息处理记录, 即向消息记录表 中与消息 a对应的条目中的 "提交时间 "加入执行单元 2将处理消息 a所得的 新消息存入临时队列 2的时间, 以及向 "临时队列地址"属性中加入执行单元 2存入输出的新消息的临时队列 2的地址; 由于此时在消息记录表中 , 消息 a 的条目中的 "提交时间"属性的值仍为空, 所以该执行单元 2的写入消息处理 记录的写入操作也满足写入条件, 确定写入成功。  Step S808: After processing the message a and storing all the generated new messages into the temporary queue 2, the execution unit 2 starts writing the message processing record to the message record table, that is, corresponding to the message a in the message record table. The "commit time" in the entry joins the execution unit 2 to store the new message obtained by processing the message a into the temporary queue 2, and the temporary queue for adding the new message of the execution unit 2 to the output of the "temporary queue address" attribute. Address of 2; since the value of the "commit time" attribute in the entry of the message a is still empty in the message record table at this time, the write operation of the write message processing record of the execution unit 2 also satisfies the write condition , to determine the success of the write.
步骤 S809:执行单元 2在确认消息处理记录写入成功后,将该执行单元 2 的临时队列 2中的消息全部转移至输出队列中。  Step S809: After the acknowledgment message processing record is successfully written, the execution unit 2 transfers all the messages in the temporary queue 2 of the execution unit 2 to the output queue.
步骤 S810: 在执行单元 2将临时队列 2中的消息全部转移完后, 针对消 息 a向消息记录表中写入消息完成记录, 即向消息 a对应的条目中的 "完成时 间" 属性中写入执行单元 2转移完临时队列 2中的时间。 步骤 S811 : 执行单元 2从输入队列中删除处理完的消息 a。 Step S810: After the execution unit 2 transfers all the messages in the temporary queue 2, write a message completion record to the message record table for the message a, that is, write to the "Completion Time" attribute in the entry corresponding to the message a. Execution unit 2 transfers the time in temporary queue 2. Step S811: The execution unit 2 deletes the processed message a from the input queue.
由此可见, 当某个执行单元从输入队列中获取消息后,如果在处理过程中 发生故障, 则由于 SQS的消息处理超时重现机制, 这个未被处理完的消息会 重新出现在输入队列中。进而另外一个执行单元会获取到这个消息, 并重新进 行处理,从而保证业务可以继续完成。 同时由于本发明实施例中对于写入记录 的条件限制,使得最终针对同一个消息的处理, 只有一个临时队列中的处理结 果被转移至输出队列中, 避免针对同一个消息的处理输出重复处理结果的问 题。  It can be seen that when an execution unit obtains a message from the input queue, if a failure occurs during processing, the unprocessed message will reappear in the input queue due to the message processing timeout replay mechanism of the SQS. . In turn, another execution unit will get this message and re-process it to ensure that the business can continue. At the same time, due to the condition limitation of the write record in the embodiment of the present invention, only the processing result in the temporary queue is transferred to the output queue for the processing of the same message, thereby avoiding the repeated processing result for the processing output of the same message. The problem.
图 9示出的是本发明实施例中在第 N个业务步骤中的某个执行单元在消 息处理结束后发生故障后实现消息重新处理的流程图, 具体包括:  FIG. 9 is a flow chart showing the re-processing of a message after a failure of an execution unit in the Nth service step after the end of the message processing in the embodiment of the present invention, specifically including:
步骤 S901: 执行单元 1从输入队列中获取消息 a。  Step S901: The execution unit 1 acquires the message a from the input queue.
步骤 S902: 执行单元 1向消息记录表中写入消息获取记录, 进而在消息 记录表中为该消息 a创建一个条目, 并在该条目中的 "接收时间 " 和 "执行单 元 ID"两个属性中分别加入执行单元 1获取消息 a的时间和执行单元 1的 ID, 经过消息获取记录写入条件 (即该消息 a的条目中的 "提交时间"属性的值为 空) 的判断, 确定写入成功。  Step S902: The execution unit 1 writes a message acquisition record to the message record table, and further creates an entry for the message a in the message record table, and two attributes of "reception time" and "execution unit ID" in the entry. The time is added to the execution unit 1 to obtain the message a and the ID of the execution unit 1, respectively, and the message is obtained by the message acquisition record writing condition (that is, the value of the "commit time" attribute in the entry of the message a is empty), and the writing is determined. success.
步骤 S903: 执行单元 1开始运行第 N个业务步骤的业务程序对其获取的 消息 a进行处理, 并同时将产生新的消息存入到临时队列 1中。  Step S903: The execution unit 1 starts the business program running the Nth business step to process the message a obtained, and simultaneously stores the generated new message into the temporary queue 1.
步骤 S904: 执行单元 1在处理完消息 a并将所产生的新消息全部存入到 临时队列 1中之后, 向消息记录表中开始写入消息处理记录, 即向消息记录表 中与消息 a对应的条目中的 "提交时间 "加入执行单元 1将处理消息 a所得的 新消息存入临时队列 1的时间, 以及向 "临时队列地址"属性中加入执行单元 1存入输出的新消息的临时队列 1的地址; 由于在执行单元 1针对消息 a写入 消息处理记录时, 消息 a的条目中的 "提交时间"属性的值仍然为空, 所以满 足写入条件, 确认写入成功。  Step S904: After processing the message a and storing all the generated new messages into the temporary queue 1, the execution unit 1 starts writing the message processing record to the message record table, that is, corresponding to the message a in the message record table. The "commit time" in the entry joins the time when the execution unit 1 stores the new message obtained by processing the message a into the temporary queue 1, and the temporary queue that adds the new message of the execution unit 1 to the output to the "temporary queue address" attribute. Address of 1; Since the value of the "commit time" attribute in the entry of the message a is still empty when the execution unit 1 writes the message processing record for the message a, the write condition is satisfied, and the write is confirmed to be successful.
步骤 S905:执行单元 1在确认消息处理记录写入成功后,从该执行单元 1 的临时队列 1中获取消息, 并开始向输出队列中转移。  Step S905: After confirming that the message processing record is successfully written, the execution unit 1 acquires a message from the temporary queue 1 of the execution unit 1, and starts to transfer to the output queue.
步骤 S906: 执行单元 1在转移消息的过程中, 发生故障, 临时队列 1 中 的消息没有被完全转移完。 步骤 S907: 执行单元 2从输入队列中获取同一消息 a。 Step S906: In the process of transferring the message, the execution unit 1 fails, and the message in the temporary queue 1 is not completely transferred. Step S907: The execution unit 2 acquires the same message a from the input queue.
步骤 S908: 执行单元 2向也开始向消息记录表中写入消息获取记录, 即 向消息 a的条目的 "接收时间" 和 "执行单元 ID" 两个属性中分别加入执行 单元 2获取消息 a的时间和执行单元 2的 ID。  Step S908: The execution unit 2 also starts to write a message acquisition record to the message record table, that is, adding the execution unit 2 to the two items of the "reception time" and the "execution unit ID" of the entry of the message a to obtain the message a. Time and ID of execution unit 2.
步骤 S909: 由于此时在消息记录表中, 消息 a的条目中的 "提交时间" 属性的值已经在步骤 S904中成功写入了非空的值,所以步骤 S908中执行单元 2的写入消息获取记录的写入操作不满足写入条件, 确定写入失败。  Step S909: Since the value of the "commit time" attribute in the entry of the message a has been successfully written in the non-empty value in step S904 in the message record table at this time, the write message of the unit 2 is executed in step S908. The write operation to get the record does not satisfy the write condition, and the write failure is determined.
步骤 S910: 执行单元 2在获知消息处理记录写入失败后, 从消息记录表 中获取消息 a的条目中的各属性值, 得到临时队列地址的属性值, 在本例中为 临时队列 1的地址。  Step S910: After obtaining the write failure of the message processing record, the execution unit 2 obtains the attribute values in the entry of the message a from the message record table, and obtains the attribute value of the temporary queue address, which is the address of the temporary queue 1 in this example. .
步骤 S911 : 执行单元 2根据临时队列 1的地址, 将临时队列 1 中的消息 全部转移至输出队列中。  Step S911: The execution unit 2 transfers all the messages in the temporary queue 1 to the output queue according to the address of the temporary queue 1.
步骤 S912: 在执行单元 2将临时队列 2中的消息全部转移完后, 针对消 息 a向 SDB中写入消息完成记录, 即向消息 a对应的条目中的 "完成时间" 属性中写入执行单元 2转移完临时队列 2中的时间。  Step S912: After the execution unit 2 completely transfers the messages in the temporary queue 2, write a message completion message to the SDB for the message a, that is, write the execution unit to the "Completion Time" attribute in the entry corresponding to the message a. 2 Transfer the time in the temporary queue 2.
步骤 S913: 执行单元 2从输入队列中删除处理完的消息 a。  Step S913: The execution unit 2 deletes the processed message a from the input queue.
由此可见, 某个执行单元针对一条消息处理完成后,如果在将临时队列中 的处理结果向输出队列转移的过程中发生故障, 则因为由于 SQS的消息处理 超时重现机制, 这个消息会重新出现在输入队列中。进而另外一个执行单元会 获取到这个消息, 而实际上之前获取该消息的执行单元已经把该消息处理完 毕, 只是临时队列中的处理结果还未完全转移完毕,但由于本发明实施例中关 于消息获取记录的写入条件限制,使得后获取该消息的执行单元不会再重复处 理一遍, 而是获取了发生故障的执行单元的临时队列的地址, 并将该临时队列 中未被转移走的消息继续全部转移至输出队列中。由此不仅保证了业务的继续 完成, 而且还避免了重复执行处理程序, 缩短时间; 进一步地, 如果不采用本 发明实施例中关于消息获取记录写入条件的限制,后来的执行单元 2不仅会重 复对同一消息 a执行业务处理程序,而且还会继续在其对应的临时队列 2存入 输出的新消息, 并进一步将临时队列 2中的消息全部转移至输出队列中, 而实 际上,在之前已经由执行单元 1将临时队列 1中项部分相同处理结果转移至输 出队列中了, 因此这就会造成针对同一消息输出重复的处理结果的问题。 It can be seen that after an execution unit completes processing for one message, if a failure occurs in the process of transferring the processing result in the temporary queue to the output queue, the message will be re-since because the SQS message processing timeout replay mechanism Appears in the input queue. Then another execution unit will obtain the message, but in fact, the execution unit that previously obtained the message has processed the message, but the processing result in the temporary queue has not been completely transferred, but due to the message in the embodiment of the present invention Obtaining the write condition limit of the record, so that the execution unit that obtains the message later does not repeat the process again, but acquires the address of the temporary queue of the failed execution unit, and the message that has not been transferred in the temporary queue Continue all transfer to the output queue. This not only ensures the continued completion of the service, but also avoids the repeated execution of the processing program and shortens the time; further, if the limitation of the message acquisition record writing condition in the embodiment of the present invention is not adopted, the subsequent execution unit 2 will not only Repeatedly executing the business processing program for the same message a, and will continue to store the output new message in its corresponding temporary queue 2, and further transfer all the messages in the temporary queue 2 to the output queue, but actually, before The same processing result of the item in the temporary queue 1 has been transferred to the input by the execution unit 1. Out of the queue, so this will cause problems with duplicate processing results for the same message output.
本发明实施例还相应提供一种分布式作业系统的执行单元,该执行单元用 于在其所在的业务步骤中针对从输入队列中取出的每条待处理消息进行处理, 如图 10所示, 该执行单元包括: An embodiment of the present invention further provides an execution unit of a distributed operation system, where the execution unit is configured to process each pending message taken from an input queue in a service step in which it is located, as shown in FIG. The execution unit includes:
业务处理单元 1001 , 用于针对从输入队列中所获取的一条待处理消息, 运行该执行单元所在的业务步骤的业务处理程序,产生至少一条业务处理结果 消息;  The service processing unit 1001 is configured to generate, according to a to-be-processed message obtained from the input queue, a service processing program that runs the service step where the execution unit is located, and generate at least one service processing result message;
处理结果保存单元 1002, 用于将产生的业务处理结果消息存入该执行单 元对应的临时队列中;  The processing result saving unit 1002 is configured to store the generated service processing result message in a temporary queue corresponding to the execution unit;
第一处理结果存入判断单元 1003 , 用于判断是否还没有其他执行单元将 处理该条待处理消息所输出的业务处理结果消息存入所述其他执行单元对应 的临时队列中,如果没有, 则将所述当前执行单元对应的临时队列作为当前队 歹 |J , 如果有, 则触发处理完毕判断单元 1004工作;  The first processing result is stored in the judging unit 1003, and is configured to determine whether the other execution unit has not yet stored the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, if not, The temporary queue corresponding to the current execution unit is used as the current queue J|J, and if so, the trigger processing completion determining unit 1004 operates;
处理完毕判断单元 1004, 用于判断上述待处理消息是否被其他执行单元 完全处理完毕,对于未完全处理完毕的情况,将所述其他执行单元的临时队列 中、已经存入对该条待处理消息处理所得的业务处理结果消息的临时队列作为 当前临时队列;  The processing completion determining unit 1004 is configured to determine whether the to-be-processed message is completely processed by other execution units, and if the information is not completely processed, the pending queue of the other execution unit is already stored in the pending message. The temporary queue for processing the obtained service processing result message is used as the current temporary queue;
处理结果转移单元 1005 , 用于将当前临时队列中的业务处理结果消息全 部转移至输出队列中, 至此该条待处理消息被完全处理完毕。  The processing result transfer unit 1005 is configured to transfer all the service processing result messages in the current temporary queue to the output queue, and the to-be-processed message is completely processed.
由此可见, 本发明实施例提供的执行单元中,在处理结果转移单元将针对 一个待处理消息进行处理得到的业务处理结果消息转移至输出队列之前,都要 先经过处理完毕判断单元判断是否还没有其他执行单元将处理该条待处理消 息所得的业务处理结果消息存入了对应的临时队列中,只有判断结果为没有的 情况,该执行单元中的处理结果转移单元才会将该执行单元输出的业务处理结 果消息转移至输出队列中; 否则, 处理结果转移会将之前由其他执行单元已经 处理得到的业务处理结果消息转移至输出队列中。这样可以保证对于输入队列 中的同一待处理消息,只有一个执行单元处理输出的业务处理结果消息最终会 送入输出队列中,避免针对同一个待处理消息, 向输出队列中输出重复的业务 处理结果消息。 It can be seen that, in the execution unit provided by the embodiment of the present invention, before the processing result transfer unit transfers the service processing result message obtained by processing the to-be-processed message to the output queue, the processing completion judgment unit first determines whether the device still returns No other execution unit stores the service processing result message obtained by processing the to-be-processed message into the corresponding temporary queue. If the judgment result is not, the processing result transfer unit in the execution unit outputs the execution unit. The business process result message is transferred to the output queue; otherwise, the process result transfer will transfer the business process result message that has been processed by other execution units to the output queue. This ensures that for the same pending message in the input queue, only one execution unit processes the output of the business processing result message. It is sent to the output queue to avoid outputting duplicate service processing result messages to the output queue for the same pending message.
与前面方法实施例中的论述类似,上述执行单元的实施例中提供的执行单 元虽然保证了针对同一个待处理消息,不会向输出队列中输出重复的业务处理 结果消息,但是也可能会出现这样的情况: 即当一个执行单元针对一条一条待 处理消息执行业务处理程序之前,可能已经有其他执行单元(例如执行单元 B ) 对该待处理消息执行了相同的业务处理程序,并已经将所输出的业务处理结果 消息存入对应的临时队列中, 但是由于执行单元 A在将其临时队列中的业务 处理结果消息转移至输出队列之前时, 才会判断出执行单元 B 已经处理过该 消息, 并已经将输出的消息存入执行单元 B的临时队列中, 但是执行单元 A 仍然会对同一待处理消息执行业务处理程序,这实际上也造成了处理资源的浪 费。  Similar to the discussion in the previous method embodiment, the execution unit provided in the embodiment of the above execution unit ensures that duplicate service processing result messages are not output to the output queue for the same pending message, but may also occur. Such a situation: that is, before an execution unit executes a business process for a piece of pending message, there may already be other execution units (such as execution unit B) that perform the same business process on the message to be processed, and have already The output service processing result message is stored in the corresponding temporary queue, but since the execution unit A transfers the service processing result message in the temporary queue to the output queue, it is determined that the execution unit B has processed the message. The output message has been stored in the temporary queue of execution unit B, but execution unit A still executes the business processing program for the same pending message, which actually causes waste of processing resources.
为了避免这种可能导致的浪费现象,在本发明实施例中还提出了一种优化 的方法, 如图 11所示, 在上述实施例的基石出上还增加了第二处理结果存入判 断单元 1006。 该第二处理结果存入判断单元 1006用于在该业务处理单元工作 之前,判断是否有还有其他执行单元将处理该条待处理消息所输出的业务处理 结果消息存入了其对应的临时队列中, 如果没有, 则通知上述业务处理单元 1001进行工作; 如果有, 则通知处理完毕判断单元 1004进行工作。  In order to avoid such a waste phenomenon, an optimization method is also proposed in the embodiment of the present invention. As shown in FIG. 11, the second processing result is added to the judgment unit on the basis of the above embodiment. 1006. The second processing result storage determining unit 1006 is configured to determine, before the service processing unit works, whether another execution unit stores the service processing result message outputted by the processing of the to-be-processed message into its corresponding temporary queue. If not, the service processing unit 1001 is notified to perform the operation; if so, the notification processing completion unit 1004 performs the operation.
在图 11中示出的与图 10中附图标记相同的单元的结构和功能是相同的, 可以参照上述实施例中对于图 10中的相关单元的描述, 这里不再贅述。 在本发明一个具体的实施例中, 针对每个业务步骤各创建一个消息记录 表,在所述消息记录表中为对应业务步骤的输入队列中的每条待处理消息创建 一个条目,此时上述图 10和图 11示出的执行单元中还包括在向该消息记录表 中写入各种记录的单元,并且相应的判断条件也是根据写入记录是否成功来确 定的。  The structure and function of the unit shown in FIG. 11 which is the same as the reference numeral in FIG. 10 are the same. Reference may be made to the description of the relevant unit in FIG. 10 in the above embodiment, and details are not described herein again. In a specific embodiment of the present invention, a message record table is created for each service step, and an entry is created in the message record table for each pending message in the input queue of the corresponding service step. The execution unit shown in Figs. 10 and 11 further includes means for writing various records in the message record table, and the corresponding judgment condition is also determined based on whether or not the write record is successful.
具体地, 上述执行单元可以进一步包括处理记录写入单元, 用于在所述处 理结果保存单元将处理所述处理消息而产生的业务处理结果消息全部存入该 当前执行单元对应的临时队列中以后,向消息记录表中与该待处理消息对应的 条目中写入消息处理记录, 写入成功的条件是该条目中的消息处理记录为空。 此时第一处理结果存入判断单元 1003可以包括:处理记录写入判断单元, 用于判断所述处理记录写入单元针对该待处理消息向消息记录表中写入消息 处理记录是否成功,如果写入成功, 则判定还没有其他执行单元将处理该条待 处理消息所输出的业务处理结果消息存入所述其他执行单元对应的临时队列 中,如果写入失败, 则判定有其他执行单元将处理该条待处理消息所输出的业 务处理结果消息存入所述其他执行单元对应的临时队列中。 Specifically, the execution unit may further include a processing record writing unit, configured to: after the processing result saving unit stores all the service processing result messages generated by processing the processing message into the temporary queue corresponding to the current execution unit, To the message record table corresponding to the pending message A message processing record is written in the entry, and the condition for successful writing is that the message processing record in the entry is empty. At this time, the first processing result storage unit 1003 may include: a processing record writing determining unit, configured to determine whether the processing record writing unit writes the message processing record to the message recording table for the to-be-processed message, if If the write succeeds, it is determined that no other execution unit stores the service processing result message outputted by the processing of the pending message into the temporary queue corresponding to the other execution unit. If the write fails, it is determined that other execution units will The service processing result message outputted by the processing of the to-be-processed message is stored in a temporary queue corresponding to the other execution units.
此外, 对于图 11 中示出的执行单元, 该执行单元还可以进一步包括获取 记录写入单元, 用于在该执行单元从输入队列中获取一条待处理消息后, 向消 息记录表中与该待处理消息对应的条目中写入消息获取记录,写入成功的条件 是该条目中的消息处理记录为空。  In addition, for the execution unit shown in FIG. 11, the execution unit may further include an acquisition record writing unit, configured to: after the execution unit acquires a to-be-processed message from the input queue, to the message record table The message acquisition record is written in the entry corresponding to the processing message, and the condition for successful writing is that the message processing record in the entry is empty.
此时, 第二处理结果存入判断单元 1006包括: 获取记录写入判断单元, 用于判断所述获取记录写入单元针对该待处理消息向消息记录表中写入消息 获取记录是否成功。  At this time, the second processing result storage unit 1006 includes: an acquisition record writing determination unit, configured to determine whether the acquisition record writing unit writes a message to the message record table for the to-be-processed message to obtain whether the record is successful.
另外,针对图 10和图 11示出的执行单元,还可以包括完成记录写入单元, 用于在所述处理结果转移单元将当前临时队列中的业务处理结果消息全部转 移至输出队列以后,向消息记录表中与该待处理消息对应的条目中写入消息完 成记录;  In addition, the execution unit shown in FIG. 10 and FIG. 11 may further include a completion record writing unit, configured to: after the processing result transfer unit transfers all the service processing result messages in the current temporary queue to the output queue, Writing a message completion record in an entry corresponding to the to-be-processed message in the message record table;
此时处理完毕判断单元包括: 完成记录写入判断单元, 用于判断与所述待 处理消息对应的条目中是否已经写入消息完成记录,如果已经写入, 则判定待 处理消息已经被其他执行单元完全处理完毕,如果还未写入, 则判定待处理消 息还未被其他执行单元完全处理完毕。  The processing completion judging unit includes: a completion record writing judging unit, configured to determine whether a message completion record has been written in an entry corresponding to the to-be-processed message, and if it has been written, determining that the to-be-processed message has been executed by another The unit is completely processed, and if it has not been written, it is determined that the pending message has not been completely processed by other execution units.
此外, 本发明另一个实施例还提供一种分布式作业系统, 包括多个上述实 施例中的执行单元和存储消息记录表的存储单元。  Further, another embodiment of the present invention provides a distributed operating system including an execution unit of the above-described embodiments and a storage unit that stores a message recording table.
需要说明的是, 如果一个待处理单元已经被一个执行单元完全处理完毕, 将业务处理结果输出至输出队列后, 可以将该待处理消息进行删除,基于这样 的考虑, 本发明实施例中的执行单元还可以包括: 删除单元, 用于在所述处理 结果转移单元将待处理消息处理完毕后, 将该待处理消息从输入队列中删除。  It should be noted that, if a to-be-processed unit has been completely processed by an execution unit, and the service processing result is output to the output queue, the to-be-processed message may be deleted. Based on such considerations, the execution in the embodiment of the present invention is performed. The unit may further include: a deleting unit, configured to delete the to-be-processed message from the input queue after the processing result forwarding unit processes the to-be-processed message.
在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和方 法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示意性 的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现时可以有另 外的划分方式, 例如多个单元或组件可以结合或者可以集成到另一个系统, 或 一些特征可以忽略, 或不执行。 另一点, 所显示或讨论的相互之间的耦合或直 接耦合或通信连接可以是通过一些接口, 装置或单元的间接耦合或通信连接, 可以是电性, 机械或其它的形式。 所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为 单元显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者 也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部 单元来实现本实施例方案的目的。 另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元中, 也可以是各个单元单独物理存在 ,也可以两个或两个以上单元集成在一个单元 中。 所述功能可以存储在一个计算机可读取存储介质中,包括若干指令用以使 得一台计算机设备 (可以是个人计算机, 服务器, 或者网络设备等)执行本发 明各个实施例所述方法的全部或部分步骤。 而前述的存储介质包括: U盘、 移 动硬盘、 只读存储器(ROM, Read-Only Memory )、 随机存取存储器 ( RAM, Random Access Memory )、 磁碟或者光盘等各种可以存储程序代码的介质。 In the several embodiments provided herein, it should be understood that the disclosed systems, devices, and parties The law can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment. In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The functions may be stored in a computer readable storage medium, including instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform all of the methods described in various embodiments of the present invention or Part of the steps. The foregoing storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .
以上公开的仅为本发明的几个具体实施例,但本发明并非局限于此,任何 本领域的技术人员能思之的变化, 都应落在本发明的保护范围内。 The above disclosure is only a few specific embodiments of the present invention, but the present invention is not limited thereto, and any changes that can be made by those skilled in the art should fall within the protection scope of the present invention.

Claims

权 利 要 求 Rights request
1、 一种分布式作业系统的业务处理方法, 其特征在于, 在每个业务步骤 中的执行单元针对从该业务步骤的输入队列中取出的每条待处理消息执行如 下操作:  A service processing method for a distributed operating system, characterized in that an execution unit in each service step performs the following operations for each pending message retrieved from an input queue of the service step:
当前执行单元针对从输入队列中所获取的一条待处理消息 ,运行该执行单 元所在业务步骤的业务处理程序, 产生至少一条业务处理结果消息;  The current execution unit, for a message to be processed obtained from the input queue, runs a service processing program of the business step where the execution unit is located, and generates at least one service processing result message;
所述当前执行单元将产生的业务处理结果消息存入该当前执行单元对应 的临时队列中;  The current execution unit stores the generated service processing result message in a temporary queue corresponding to the current execution unit;
判断是否还没有其他执行单元将处理该条待处理消息所输出的业务处理 结果消息存入所述其他执行单元对应的临时队列中,如果没有, 则将所述当前 执行单元对应的临时队列作为当前临时队列,并且当前执行单元将所述当前临 时队列中的业务处理结果消息全部转移至输出队列中,至此该条待处理消息被 当前执行单元完全处理完毕,如果有, 则判断所述待处理消息是否已经被其他 执行单元完全处理完毕,对于未完全处理完毕的情况,将所述其他执行单元的 临时队列中、已经存入对该条待处理消息处理所得的业务处理结果消息的临时 队列作为当前临时队列。  Determining whether there is no other execution unit to store the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if not, the temporary queue corresponding to the current execution unit is used as the current a temporary queue, and the current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, so that the to-be-processed message is completely processed by the current execution unit, and if so, the pending message is determined. Whether it has been completely processed by other execution units. For the case where the processing is not completely processed, the temporary queue of the other execution unit that has been stored in the temporary processing queue for processing the processed message is processed as the current Temporary queue.
2、 根据权利要求 1所述的方法, 其特征在于, 所述方法还包括: 在当前执行单元针对所获取的待处理消息运行业务处理程序之前,执行如 下步骤:判断是否还没有其他执行单元将处理该条待处理消息所输出的业务处 理结果消息存入所述其他执行单元对应的临时队列中,如果没有, 则继续执行 针对所获取的待处理消息运行所述业务处理程序; 如果有, 则返回执行当前执 行单元将所述当前临时队列中的业务处理结果消息全部转移至输出队列中,至 此该条待处理消息被当前执行单元完全处理完毕的步骤。  The method according to claim 1, wherein the method further comprises: before the current execution unit runs the service processing program for the acquired to-be-processed message, performing the following steps: determining whether there are no other execution units yet The service processing result message outputted by the processing of the to-be-processed message is stored in the temporary queue corresponding to the other execution unit, and if not, the execution of the service processing program for the acquired pending message is continued; if yes, Returning to the execution execution unit, all the business processing result messages in the current temporary queue are transferred to the output queue, and the processing of the pending processing message is completely processed by the current execution unit.
3、 根据权利要求 1或 2所述的方法, 其特征在于, 所述方法还包括: 针 对每个业务步骤各创建一个消息记录表,在所述消息记录表中为对应业务步骤 的输入队列中的每条待处理消息创建一个条目;  The method according to claim 1 or 2, wherein the method further comprises: creating a message record table for each service step, where the message record table is in an input queue corresponding to the service step Create an entry for each pending message;
在当前执行单元将处理所述待处理消息而产生的业务处理结果消息全部 存入该当前执行单元对应的临时队列中以后,所述当前执行单元向消息记录表 中与所述待处理消息对应的条目中写入消息处理记录,写入成功的条件是该条 目中的消息处理记录为空; All the business processing result messages generated by the current execution unit to process the to-be-processed message After being stored in the temporary queue corresponding to the current execution unit, the current execution unit writes a message processing record to the entry corresponding to the to-be-processed message in the message record table, and the condition for successful writing is the message in the entry. Processing record is empty;
所述判断是否还没有其他执行单元将处理该条待处理消息所输出的业务 处理结果消息存入所述其他执行单元对应的临时队列中包括:  The determining whether the other execution unit has not processed the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit includes:
判断所述当前执行单元针对该待处理消息向消息记录表中写入消息处理 记录是否成功, 如果写入成功, 则判定没有, 如果写入失败, 则判定有。  Determining whether the current execution unit writes the message processing record to the message record table for the pending message is successful. If the writing is successful, the determination is not. If the writing fails, the determination is yes.
4、 根据权利要求 2所述的方法, 其特征在于, 所述方法还包括: 所述方 法还包括: 针对每个业务步骤各创建一个消息记录表,在所述消息记录表中为 对应业务步骤的输入队列中的每条待处理消息创建一个条目;  The method according to claim 2, wherein the method further comprises: creating a message record table for each service step, and corresponding service steps in the message record table. Create an entry for each pending message in the input queue;
在当前执行单元将处理所述待处理消息而产生的业务处理结果消息全部 存入该当前执行单元对应的临时队列中以后,所述当前执行单元向消息记录表 中与所述待处理消息对应的条目中写入消息处理记录,写入成功的条件是该条 目中的消息处理记录为空;  After the current execution unit stores the service processing result message generated by processing the to-be-processed message in the temporary queue corresponding to the current execution unit, the current execution unit corresponds to the to-be-processed message in the message record table. The message processing record is written in the entry, and the condition for successful writing is that the message processing record in the entry is empty;
在当前执行单元从输入队列中获取一条待处理消息后,向消息记录表中与 该待处理消息对应的条目中写入消息获取记录,写入成功的条件是该条目中的 消息处理记录为空;  After the current execution unit obtains a pending message from the input queue, the message acquisition record is written into the entry corresponding to the to-be-processed message in the message record table, and the condition for successful writing is that the message processing record in the entry is empty. ;
所述判断是否还没有其他执行单元将处理该条待处理消息所输出的业务 处理结果存入所述其他执行单元对应的临时队列中包括:  The determining whether the other execution unit has not yet stored the service processing result outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit includes:
判断所述当前执行单元针对该待处理消息向消息记录表中写入消息获取 记录是否成功, 如果写入成功, 则判定没有, 如果写入失败, 则判定有。  Determining whether the current execution unit writes a message to the message record table for the pending message to obtain whether the record is successful. If the write is successful, the determination is not. If the write fails, the determination is made.
5、 根据权利要求 3或 4所述的方法, 其特征在于, 所述当前执行单元向 消息记录表中与所述待处理消息对应的条目中写入的消息处理记录中包括:所 述当前执行单元对应的临时队列地址;  The method according to claim 3 or 4, wherein the current execution unit includes, in the message processing record written in the entry corresponding to the to-be-processed message in the message record table, the current execution The temporary queue address corresponding to the unit;
所述将其他执行单元的临时队列中、已经存入对该条待处理消息处理所得 的业务处理结果消息的临时队列作为当前临时队列包括:  The temporary queue of the service processing result message that has been processed in the temporary queue of the other execution unit and has been processed into the pending processing message is used as the current temporary queue.
从所述待处理消息对应的条目中,获取已经成功写入的消息处理记录中的 临时队列地址; Obtaining, in the message processing record that has been successfully written, from the entry corresponding to the to-be-processed message Temporary queue address;
将所述获取到的临时队列地址所定位的临时队列作为当前临时队列。  The temporary queue that is located by the obtained temporary queue address is used as the current temporary queue.
6、 根据权利要求 5所述的方法, 其特征在于, 所述当前执行单元向消息 记录表中与所述待处理消息对应的条目中写入的消息处理记录中还包括:所述 当前执行单元将将处理待处理消息而产生的业务处理结果消息全部存入该当 前执行单元对应的临时队列中的提交时间;  The method according to claim 5, wherein the current execution unit further includes: the current execution unit in the message processing record written in the entry corresponding to the to-be-processed message in the message record table All the service processing result messages generated by processing the to-be-processed message are all stored in the commit queue corresponding to the current execution unit;
所述待处理消息对应条目中的消息处理记录为空是指该条目中的提交时 间为空。  The blank of the message processing record in the corresponding entry of the to-be-processed message means that the submission time in the entry is empty.
7、 根据权利要求 1或 2所述的方法, 其特征在于, 所述方法还包括: 针 对每个业务步骤各创建一个消息记录表,在所述消息记录表中为对应业务步骤 的输入队列中的每条待处理消息创建一个条目;  The method according to claim 1 or 2, wherein the method further comprises: creating a message record table for each service step, where the message record table is in an input queue corresponding to the service step Create an entry for each pending message;
当前执行单元将当前临时队列中的业务处理结果消息全部转移至输出队 列以后,所述当前执行单元还向消息记录表中与该待处理消息对应的条目中写 入消息完成记录;  After the current execution unit transfers all the service processing result messages in the current temporary queue to the output queue, the current execution unit also writes a message completion record to the entry corresponding to the to-be-processed message in the message record table;
所述判断待处理消息是否已经被其他执行单元完全处理完毕包括: 判断与所述待处理消息对应的条目中是否已经写入消息完成记录,如果已 经写入,则判定待处理消息已经被其他执行单元完全处理完毕,如果还未写入, 则判定待处理消息还未被其他执行单元完全处理完毕。  Determining whether the to-be-processed message has been completely processed by the other execution unit comprises: determining whether a message completion record has been written in the entry corresponding to the to-be-processed message, and if it has been written, determining that the pending message has been executed by another The unit is completely processed, and if it has not been written, it is determined that the pending message has not been completely processed by other execution units.
8、 根据权利要求 7所述的方法, 其特征在于, 所述当前执行单元向消息 记录表中与该待处理消息对应的条目中写入的消息完成记录中包括:当前执行 单元将当前临时队列中的业务处理结果信息全部转移至输出队列的完成时间; 所述与待处理消息对应的条目中已经写入消息完成记录是指该条目中的 完成时间不为空。  The method according to claim 7, wherein the current execution unit records the message completion record written in the entry corresponding to the to-be-processed message in the message record table, and the current execution unit includes the current temporary queue. The service processing result information in all is transferred to the completion time of the output queue; the message completion record written in the entry corresponding to the to-be-processed message means that the completion time in the entry is not empty.
9、 根据权利要求 1至 8中任意一项所述的方法, 其特征在于, 所述方法 还包括:  The method according to any one of claims 1 to 8, wherein the method further comprises:
在步骤 D 中对于完全处理完毕的情况, 所述当前执行单元从输入队列中 取出下一条待处理消息, 并返回执行步骤入。 In the case of the complete processing in step D, the current execution unit takes the next pending message from the input queue and returns to the execution step.
10、 根据权利要求 1至 8中任意一项所述的方法, 其特征在于, 所述方法 还包括: The method according to any one of claims 1 to 8, wherein the method further comprises:
在步骤 E中所述待处理消息被当前执行单元完全处理完毕后,所述当前执 行单元从输入队列中删除该待处理消息。  After the to-be-processed message is completely processed by the current execution unit in step E, the current execution unit deletes the to-be-processed message from the input queue.
11、 一种分布式作业系统的执行单元, 其特征在于, 该执行单元用于在其 所在的业务步骤中针对从输入队列中取出的每条待处理消息进行处理,该执行 单元包括:  An execution unit of a distributed operating system, wherein the execution unit is configured to process, in a business step in which it is located, each pending message retrieved from an input queue, the execution unit comprising:
业务处理单元, 用于针对从输入队列中所获取的一条待处理消息,运行该 执行单元所在的业务步骤的业务处理程序, 产生至少一条业务处理结果消息; 处理结果保存单元,用于将产生的业务处理结果消息存入该执行单元对应 的临时队列中;  a service processing unit, configured to: for a pending message obtained from the input queue, run a service processing program of the service step where the execution unit is located, generate at least one service processing result message; and process a result saving unit, which is to be generated The service processing result message is stored in a temporary queue corresponding to the execution unit;
第一处理结果存入判断单元,用于判断是否还没有其他执行单元将处理该 条待处理消息所输出的业务处理结果消息存入所述其他执行单元对应的临时 队列中, 如果没有, 则将所述当前执行单元对应的临时队列作为当前队列, 如 果有, 则触发处理完毕判断单元工作;  The first processing result is stored in the judging unit, and is configured to determine whether the other execution unit has stored the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, if not, The temporary queue corresponding to the current execution unit is used as the current queue, and if so, the processing completion judgment unit is triggered to work;
处理完毕判断单元,用于判断所述待处理消息是否被其他执行单元完全处 理完毕, 对于未完全处理完毕的情况, 将所述其他执行单元的临时队列中、 已 经存入对该条待处理消息处理所得的业务处理结果消息的临时队列作为当前 临时队列;  The processing completion judging unit is configured to determine whether the to-be-processed message is completely processed by other execution units, and if the incomplete processing is completed, the pending queue of the other execution unit is already stored in the pending message. The temporary queue for processing the obtained service processing result message is used as the current temporary queue;
处理结果转移单元,用于将当前临时队列中的业务处理结果消息全部转移 至输出队列中, 至此该条待处理消息被完全处理完毕。  The processing result transfer unit is configured to transfer all the service processing result messages in the current temporary queue to the output queue, and the pending message is completely processed.
12、 根据权利要求 11所述的执行单元, 其特征在于, 该执行单元还包括: 第二处理结果存入判断单元, 用于在所述业务处理单元工作之前, 判断是 否有还有其他执行单元将处理该条待处理消息所输出的业务处理结果消息存 入了其对应的临时队列中, 如果没有, 则通知所述业务处理单元进行工作; 如 果有, 则通知所述处理完毕判断单元进行工作。  The execution unit according to claim 11, wherein the execution unit further comprises: a second processing result storage determining unit, configured to determine whether there are other execution units before the service processing unit works Transmitting the service processing result message outputted by the processing of the to-be-processed message into its corresponding temporary queue. If not, notifying the service processing unit to perform the work; if yes, notifying the processing completion determining unit to work .
13、 根据权利要求 11或 12所述的执行单元, 其特征在于, 针对每个业务 步骤各创建一个消息记录表,在所述消息记录表中为对应业务步骤的输入队列 中的每条待处理消息创建一个条目; 13. An execution unit according to claim 11 or 12, characterized in that, for each service Each of the steps creates a message record table in which an entry is created for each pending message in the input queue of the corresponding service step;
该执行单元还包括: 处理记录写入单元, 用于在所述处理结果保存单元将 处理所述处理消息而产生的业务处理结果消息全部存入该当前执行单元对应 的临时队列中以后,向消息记录表中与该待处理消息对应的条目中写入消息处 理记录, 写入成功的条件是该条目中的消息处理记录为空;  The execution unit further includes: a processing record writing unit, configured to: after the processing result saving unit stores all the service processing result messages generated by processing the processing message into the temporary queue corresponding to the current execution unit, to the message The message processing record is written in the entry corresponding to the to-be-processed message in the record table, and the condition for successful writing is that the message processing record in the entry is empty;
所述第一处理结果存入判断单元包括: 处理记录写入判断单元, 用于判断 所述处理记录写入单元针对该待处理消息向消息记录表中写入消息处理记录 是否成功,如果写入成功, 则判定还没有其他执行单元将处理该条待处理消息 所输出的业务处理结果消息存入所述其他执行单元对应的临时队列中,如果写 入失败,则判定有其他执行单元将处理该条待处理消息所输出的业务处理结果 消息存入所述其他执行单元对应的临时队列中。  The first processing result storage determining unit includes: a processing record writing determining unit, configured to determine whether the processing record writing unit writes a message processing record to the message recording table for the to-be-processed message, if the writing is successful, if the writing is successful If it is successful, it is determined that no other execution unit stores the service processing result message outputted by the processing of the to-be-processed message into the temporary queue corresponding to the other execution unit, and if the write fails, it is determined that other execution units will process the The service processing result message outputted by the to-be-processed message is stored in a temporary queue corresponding to the other execution units.
14、 根据权利要求 12所述的执行单元, 其特征在于, 针对每个业务步骤 各创建一个消息记录表,在所述消息记录表中为对应业务步骤的输入队列中的 每条待处理消息创建一个条目;  14. The execution unit according to claim 12, wherein a message record table is created for each service step, and each message to be processed in the input queue of the corresponding service step is created in the message record table. An entry;
该执行单元还包括:  The execution unit also includes:
处理记录写入单元,用于在所述处理结果保存单元将处理所述处理消息而 产生的业务处理结果消息全部存入该当前执行单元对应的临时队列中以后,向 消息记录表中与该待处理消息对应的条目中写入消息处理记录,写入成功的条 件是该条目中的消息处理记录为空;  a processing record writing unit, configured to: after the processing result saving unit stores all the service processing result messages generated by processing the processing message into the temporary queue corresponding to the current execution unit, to the message record table The message processing record is written in the entry corresponding to the processing message, and the condition for successful writing is that the message processing record in the entry is empty;
获取记录写入单元,用于在该执行单元从输入队列中获取一条待处理消息 后, 向消息记录表中与该待处理消息对应的条目中写入消息获取记录, 写入成 功的条件是该条目中的消息处理记录为空;  Obtaining a record writing unit, configured to: after the execution unit acquires a to-be-processed message from the input queue, write a message acquisition record to an entry corresponding to the to-be-processed message in the message record table, and the condition for successful writing is The message processing record in the entry is empty;
所述第二处理结果存入判断单元包括: 获取记录写入判断单元, 用于判断 所述获取记录写入单元针对该待处理消息向消息记录表中写入消息获取记录 是否成功。  The second processing result storage determining unit includes: an obtaining record writing determining unit, configured to determine whether the acquiring record writing unit successfully writes a record to the message record table for the to-be-processed message.
15、 根据权利要求 11或 12所述的执行单元, 其特征在于, 针对每个业务 步骤各创建一个消息记录表,在所述消息记录表中为对应业务步骤的输入队列 中的每条待处理消息创建一个条目; 15. An execution unit according to claim 11 or 12, characterized in that for each service Each of the steps creates a message record table in which an entry is created for each pending message in the input queue of the corresponding service step;
该执行单元还包括:  The execution unit also includes:
完成记录写入单元,用于在所述处理结果转移单元将当前临时队列中的业 务处理结果消息全部转移至输出队列以后,向消息记录表中与该待处理消息对 应的条目中写入消息完成记录;  Completing the record writing unit, configured to write a message to the entry corresponding to the to-be-processed message in the message record table after the processing result transfer unit transfers all the service processing result messages in the current temporary queue to the output queue. Record
所述处理完毕判断单元包括:  The processing completion determining unit includes:
完成记录写入判断单元,用于判断与所述待处理消息对应的条目中是否已 经写入消息完成记录,如果已经写入, 则判定待处理消息已经被其他执行单元 完全处理完毕,如果还未写入, 则判定待处理消息还未被其他执行单元完全处 理完毕。  Completing a record write judging unit, configured to determine whether a message completion record has been written in an entry corresponding to the to-be-processed message, and if it has been written, determining that the to-be-processed message has been completely processed by other execution units, if not yet Write, then determine that the pending message has not been completely processed by other execution units.
16、 根据权利要求 11至 15中任意一项所述执行单元, 其特征在于, 还包 括: 删除单元, 用于在所述处理结果转移单元将待处理消息处理完毕后, 将该 待处理消息从输入队列中删除。  The execution unit according to any one of claims 11 to 15, further comprising: a deleting unit, configured to: after the processing result transfer unit processes the to-be-processed message, the to-be-processed message Deleted in the input queue.
17、 一种分布式作业系统, 其特征在于, 包括多个如权利要求 11至 16中 所述的执行单元和存储消息记录表的存储单元。  A distributed operating system, comprising: a plurality of execution units as recited in claims 11 to 16 and a storage unit storing a message record table.
PCT/CN2012/073003 2012-03-26 2012-03-26 Service processing method, execution unit and system for distributed operating system WO2013143050A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2012/073003 WO2013143050A1 (en) 2012-03-26 2012-03-26 Service processing method, execution unit and system for distributed operating system
CN201280001510.XA CN104145260B (en) 2012-03-26 2012-03-26 Method for processing business, performance element and the system of a kind of distributed job system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2012/073003 WO2013143050A1 (en) 2012-03-26 2012-03-26 Service processing method, execution unit and system for distributed operating system

Publications (1)

Publication Number Publication Date
WO2013143050A1 true WO2013143050A1 (en) 2013-10-03

Family

ID=49258045

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/073003 WO2013143050A1 (en) 2012-03-26 2012-03-26 Service processing method, execution unit and system for distributed operating system

Country Status (2)

Country Link
CN (1) CN104145260B (en)
WO (1) WO2013143050A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106331153B (en) * 2016-09-20 2019-10-25 北京华为数字技术有限公司 A kind of filter method of service request, apparatus and system
CN106973065A (en) * 2017-04-28 2017-07-21 武汉票据交易中心有限公司 A kind of server event processing system and method
CN107222550B (en) * 2017-06-23 2020-07-03 武汉聚风天下科技有限公司 Server cluster processing system and method
CN107977275B (en) * 2017-12-05 2022-10-21 腾讯科技(深圳)有限公司 Task processing method based on message queue and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1908903A (en) * 2005-08-01 2007-02-07 富士通株式会社 System and method for executing job step, and computer product
CN101512527A (en) * 2006-10-05 2009-08-19 国际商业机器公司 Data processing system and method of handling requests
CN101784018A (en) * 2009-01-19 2010-07-21 中兴通讯股份有限公司 Multimedia message transmission method and device for realizing method
CN101782891A (en) * 2010-03-26 2010-07-21 中兴通讯股份有限公司 Method and system for communication of distributed system
US20110072073A1 (en) * 2009-09-21 2011-03-24 Sling Media Inc. Systems and methods for formatting media content for distribution

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6832243B1 (en) * 2000-08-15 2004-12-14 International Business Machines Corporation Methods and apparatus for defining, observing and evaluating message delivery outcome on a per-message basis
CN101582786B (en) * 2009-06-17 2012-06-13 中兴通讯股份有限公司 Instant handling method and device of instant messages

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1908903A (en) * 2005-08-01 2007-02-07 富士通株式会社 System and method for executing job step, and computer product
CN101512527A (en) * 2006-10-05 2009-08-19 国际商业机器公司 Data processing system and method of handling requests
CN101784018A (en) * 2009-01-19 2010-07-21 中兴通讯股份有限公司 Multimedia message transmission method and device for realizing method
US20110072073A1 (en) * 2009-09-21 2011-03-24 Sling Media Inc. Systems and methods for formatting media content for distribution
CN101782891A (en) * 2010-03-26 2010-07-21 中兴通讯股份有限公司 Method and system for communication of distributed system

Also Published As

Publication number Publication date
CN104145260A (en) 2014-11-12
CN104145260B (en) 2016-08-10

Similar Documents

Publication Publication Date Title
US20170193110A1 (en) Distributed system for large volume deep web data extraction
US20160275123A1 (en) Pipeline execution of multiple map-reduce jobs
US10831741B2 (en) Log-shipping data replication with early log record fetching
US20190394157A1 (en) Modification of delivered email content
US20160048430A1 (en) Method of operating a shared nothing cluster system
US9852220B1 (en) Distributed workflow management system
CN111709712B (en) Cross-system flow butt joint method and device, electronic equipment and storage medium
JP6475304B2 (en) Transaction processing method and apparatus
EP3286665B1 (en) Rich attachment regeneration
WO2017028690A1 (en) File processing method and system based on etl
WO2013143050A1 (en) Service processing method, execution unit and system for distributed operating system
WO2018028484A1 (en) Group restoration method, server, and storage medium
US20210373914A1 (en) Batch to stream processing in a feature management platform
JP2009536403A (en) Work item event processing
US11797527B2 (en) Real time fault tolerant stateful featurization
CN113760566A (en) Method, device, system and storage medium for distributed transaction processing
US20170371726A1 (en) Rapid predictive analysis of very large data sets using an actor-driven distributed computational graph
KR101639912B1 (en) Event managing system of steel process middleware
US11775864B2 (en) Feature management platform
CN114428692A (en) Data transmitting method, data receiving method, data transmitting device, data receiving device, computer equipment and storage medium
CN105630635B (en) Data disaster tolerance system and method
EP3635551A2 (en) Rapid predictive analysis of very large data sets using an actor-driven distributed computational graph
JP6036690B2 (en) Distributed execution system and distributed program execution method
JP5652281B2 (en) Business processing server, business processing method, and business processing program
JP5397076B2 (en) Job execution apparatus, job execution method, and job execution program

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12873275

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12873275

Country of ref document: EP

Kind code of ref document: A1