CN113760486A - Task processing method and task processing device - Google Patents

Task processing method and task processing device Download PDF

Info

Publication number
CN113760486A
CN113760486A CN202010769278.0A CN202010769278A CN113760486A CN 113760486 A CN113760486 A CN 113760486A CN 202010769278 A CN202010769278 A CN 202010769278A CN 113760486 A CN113760486 A CN 113760486A
Authority
CN
China
Prior art keywords
task
data
class
type
executed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010769278.0A
Other languages
Chinese (zh)
Inventor
李秀海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010769278.0A priority Critical patent/CN113760486A/en
Publication of CN113760486A publication Critical patent/CN113760486A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a task processing method and a task processing device, and relates to the technical field of computers. One embodiment of the method comprises: inquiring a mapping relation table by taking the service type as an inquiry condition to obtain a mapping record corresponding to the service type, wherein the mapping relation table records the mapping relation between the service type and the task type; constructing corresponding task data of the mapping record based on a JAVA reflection technology, and storing the task data into a task data table; and scanning the task data table by utilizing the predefined classes, acquiring the data of the task to be executed, and processing the data of the task to be executed. The implementation method can solve the technical problem of reduction of reusability of class files in the prior art by using the mapping relation table, and improves the flexibility and maintainability of codes.

Description

Task processing method and task processing device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a task processing method and a task processing apparatus.
Background
The system can support different types of services, each service has a flow arrangement algorithm, and the flow arrangement algorithm is utilized to process specific tasks corresponding to the service. In the flow arrangement algorithm, human intervention is not needed, and the tasks needing to be processed can be automatically triggered and executed as long as the time condition is reached. The task processing is mainly divided into three steps: firstly, scanning a database and inquiring data meeting conditions; secondly, executing specific logic; and thirdly, updating the data content and writing back the data content to the database.
Currently, there are mainly two ways to handle tasks: in the first mode, the three steps of task processing are not decoupled, and the functions are developed every time a task is newly added to complete the three steps of operation; and the second mode is to decouple the operation of scanning the database and the operation of executing specific logic and define the scanning class file and the interface class file of executing the logic.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: for the first mode, three steps of operation are coupled together, the reusability of class files is reduced, and a function of scanning a database to inquire data needs to be developed every time a task is newly added; and for the second mode, as the task types increase, the initialization description added in the configuration file increases exponentially, and the flexibility and maintainability of the code are reduced straightly.
Disclosure of Invention
In view of this, embodiments of the present invention provide a task processing method and a task processing apparatus, which can solve the technical problem of reducing reusability of class files in the prior art by using a mapping relation table, and improve flexibility and maintainability of codes.
To achieve the above object, according to a first aspect of an embodiment of the present invention, a task processing method is provided.
The task processing method of the embodiment of the invention comprises the following steps: inquiring a mapping relation table by taking the service type as an inquiry condition to obtain a mapping record corresponding to the service type, wherein the mapping relation table records the mapping relation between the service type and the task type; constructing task data corresponding to the mapping record based on a JAVA reflection technology, and storing the task data into a task data table; and scanning the task data table by utilizing a predefined class, acquiring task data to be executed, and processing the task data to be executed.
Optionally, the mapping relationship table includes: mapping identification fields, service data source fields, task type fields, task initial state fields and service type fields; the method further comprises the following steps: acquiring input data through a visual interface, generating a mapping record between a service type and a task type corresponding to the input data, and storing the generated mapping record into the mapping relation table; and after receiving a task canceling request, deleting the mapping record corresponding to the task canceling request from the mapping relation table.
Optionally, the constructing task data corresponding to the mapping record based on the JAVA reflection technology includes: acquiring the task type in the mapping record; traversing the mapping record, and determining a dynamic field in the mapping record; based on JAVA reflection technology, acquiring the service data corresponding to the mapping record according to the dynamic field; constructing task data corresponding to the mapping record according to the service data corresponding to the mapping record and the task type in the mapping record; wherein the task data comprises: task type, task current state, and identification of associated business data.
Optionally, the method further comprises: defining an abstract class, defining a compiling task model method, a compiling task distribution method and a scanning method in the abstract class, and defining a first global variable and a second global variable, wherein the first global variable is a task model type, and the second global variable is a task distribution type; defining a task model class, and defining a task type variable and a task execution logic in the task model class; defining a task distribution interface class, defining a task distribution method in the task distribution interface class, and defining a task operation global variable of a task operation type; defining a task operation class, and defining a task locking method, an operation executing method and a task unlocking method in the task operation class; and defining a task execution class, wherein the task execution class inherits the abstract class, and a timing execution method is defined in the task execution class.
Optionally, the scanning, by using a predefined class, the task data table to obtain task data to be executed, and processing the task data to be executed includes: calling the compiling task model method and the compiling task distribution method defined in the abstract class through the task execution class to assign values to the first global variable and the second global variable which are defined; calling the scanning method defined in the abstract class, reading the task type variable defined in the task model class, scanning the task data table according to the task type variable, and acquiring the task data to be executed; and calling the task distribution method defined in the task distribution interface class, and processing the task data to be executed according to the task execution logic defined in the task model class.
Optionally, the scanning the task data table according to the task type variable to obtain task data to be executed includes: inquiring the task data table by taking the task type variable as an inquiry condition, and judging whether optional task data corresponding to the task type variable exists in the task data table; if yes, judging whether the task state of the optional task data is waiting for processing, and if yes, determining that the optional task data is the task data to be executed.
Optionally, the invoking the task distribution method defined in the task distribution interface class and processing the to-be-executed task data according to the task execution logic defined in the task model class includes: determining a target task type corresponding to the to-be-executed task data, and calling the task distribution method to check whether a thread pool corresponding to the target task type exists in a thread pool container; if yes, processing the task data to be executed according to the task execution logic by using a thread pool corresponding to the target task type; and if the target task type does not exist, establishing a thread pool corresponding to the target task type, putting the thread pool corresponding to the target task type into the thread pool container, and processing the task data to be executed according to the task execution logic by using the thread pool corresponding to the target task type.
Optionally, the processing the task data to be executed according to the task execution logic by using the thread pool corresponding to the target task type includes: reading an empty thread in a thread pool corresponding to the target task type, and instantiating the task operation class according to the task data to be executed and the task execution logic through the empty thread; calling the task locking method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table into a locking state; calling the execution operation method defined in the task operation class, and processing the task data to be executed according to the task execution logic to obtain a processing result; and calling the unlocking task method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table to finish unlocking.
Optionally, the invoking the scanning method defined in the abstract class includes: and calling a timing execution method defined in the task execution class, and calling the scanning method defined in the abstract class in a timing mode inside the timing execution method.
To achieve the above object, according to a second aspect of an embodiment of the present invention, there is provided a task processing device.
A task processing device of an embodiment of the present invention includes: the query module is used for querying a mapping relation table by taking the service type as a query condition to obtain a mapping record corresponding to the service type, and the mapping relation table records the mapping relation between the service type and the task type; the construction module is used for constructing the task data corresponding to the mapping record based on a JAVA reflection technology and storing the task data into a task data table; and the processing module is used for scanning the task data table by utilizing a predefined class, acquiring task data to be executed and processing the task data to be executed.
Optionally, the mapping relationship table includes: mapping identification fields, service data source fields, task type fields, task initial state fields and service type fields; the apparatus further comprises a generation module configured to: acquiring input data through a visual interface, generating a mapping record between a service type and a task type corresponding to the input data, and storing the generated mapping record into the mapping relation table; and after receiving a task canceling request, deleting the mapping record corresponding to the task canceling request from the mapping relation table.
Optionally, the construction module is further configured to: acquiring the task type in the mapping record; traversing the mapping record, and determining a dynamic field in the mapping record; based on JAVA reflection technology, acquiring the service data corresponding to the mapping record according to the dynamic field; constructing task data corresponding to the mapping record according to the service data corresponding to the mapping record and the task type in the mapping record; wherein the task data comprises: task type, task current state, and identification of associated business data.
Optionally, the apparatus further comprises a defining module configured to: defining an abstract class, defining a compiling task model method, a compiling task distribution method and a scanning method in the abstract class, and defining a first global variable and a second global variable, wherein the first global variable is a task model type, and the second global variable is a task distribution type; defining a task model class, and defining a task type variable and a task execution logic in the task model class; defining a task distribution interface class, defining a task distribution method in the task distribution interface class, and defining a task operation global variable of a task operation type; defining a task operation class, and defining a task locking method, an operation executing method and a task unlocking method in the task operation class; and defining a task execution class, wherein the task execution class inherits the abstract class, and a timing execution method is defined in the task execution class.
Optionally, the processing module is further configured to: calling the compiling task model method and the compiling task distribution method defined in the abstract class through the task execution class to assign values to the first global variable and the second global variable which are defined; calling the scanning method defined in the abstract class, reading the task type variable defined in the task model class, scanning the task data table according to the task type variable, and acquiring the task data to be executed; and calling the task distribution method defined in the task distribution interface class, and processing the task data to be executed according to the task execution logic defined in the task model class.
Optionally, the processing module is further configured to: inquiring the task data table by taking the task type variable as an inquiry condition, and judging whether optional task data corresponding to the task type variable exists in the task data table; if yes, judging whether the task state of the optional task data is waiting for processing, and if yes, determining that the optional task data is the task data to be executed.
Optionally, the processing module is further configured to: determining a target task type corresponding to the to-be-executed task data, and calling the task distribution method to check whether a thread pool corresponding to the target task type exists in a thread pool container; if yes, processing the task data to be executed according to the task execution logic by using a thread pool corresponding to the target task type; and if the target task type does not exist, establishing a thread pool corresponding to the target task type, putting the thread pool corresponding to the target task type into the thread pool container, and processing the task data to be executed according to the task execution logic by using the thread pool corresponding to the target task type.
Optionally, the processing module is further configured to: reading an empty thread in a thread pool corresponding to the target task type, and instantiating the task operation class according to the task data to be executed and the task execution logic through the empty thread; calling the task locking method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table into a locking state; calling the execution operation method defined in the task operation class, and processing the task data to be executed according to the task execution logic to obtain a processing result; and calling the unlocking task method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table to finish unlocking.
Optionally, the processing module is further configured to: and calling a timing execution method defined in the task execution class, and calling the scanning method defined in the abstract class in a timing mode inside the timing execution method.
To achieve the above object, according to a third aspect of embodiments of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by one or more processors, the one or more processors realize the task processing method of the embodiment of the invention.
To achieve the above object, according to a fourth aspect of embodiments of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention has a computer program stored thereon, and when the program is executed by a processor, the program implements a task processing method of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the mapping relation table can be inquired through the service type, the mapping relation between the service type and the task type is recorded in the mapping relation table, therefore, after the mapping record is generated, the task data corresponding to the mapping record can be constructed according to the generated mapping record, then the task data is added into the task data table, so that the data corresponding to the task to be executed can be obtained through scanning the task data table, then the task data to be executed is obtained and processed by utilizing the predefined class scanning task data table, the technical problems that in the prior art, due to the fact that three steps of operation are coupled together, the reusability of class files is reduced, the function of scanning a database to inquire data needs to be developed every time a task is newly added are solved, and the flexibility and maintainability of codes can be improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a task processing method according to an embodiment of the invention;
FIG. 2 is a predefined class structure diagram according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of a task processing device according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The system can support various different types of services, each service has a flow arrangement algorithm, and the flow arrangement algorithms are different among the different types of services. For example, the system can automatically call the agent service to recharge after the user pays successfully, such as telephone fee recharge, flow recharge and the like, which are virtual services facing to common users; the system automatically sends data to a warehouse after the user successfully pays for physical services of household appliances, digital products and the like facing to common users; the method comprises the following steps that (1) after the business facing enterprise users, such as court auction, enterprise purchase and the like, is completed, due to large amount of money, the next production link can be started after the manual examination of workers is passed; after the settlement list is generated, the payment link is carried out only after the business facing enterprise users, such as enterprise settlement, and the like, pass the joint audit of the staff of the enterprises of the two parties A and B. How the system supports different types of process arrangement, and meanwhile, different types of services can be built and shared together and rapidly developed, which becomes the key of system construction. In the above-mentioned flow arrangement algorithm, the automatic calling of the agent service for recharging, the automatic sending of data to the warehouse, the automatic entering of the next link after manual review, etc. are all the automatic system initiation, and the manual triggered service flow is not needed, which can be regarded as the tasks to be executed, the tasks to be executed do not need human intervention, and the execution can be triggered automatically as long as the time condition is reached.
The existing task processing method has the problems that the reusability of class files is reduced, and the function of scanning a database to inquire data needs to be developed every time a task is newly added; the problem that the flexibility and maintainability of the code are linearly reduced along with the increase of task types exists; and the problem that tasks cannot be dynamically ended or newly added in the process arrangement link. In order to solve the above problem, an embodiment of the present invention provides a task processing method, and fig. 1 is a schematic diagram of main steps of the task processing method according to the embodiment of the present invention. As shown in fig. 1, the main steps of the task processing method may include:
step S101, a mapping relation table is inquired by taking the service type as an inquiry condition, and a mapping record corresponding to the service type is obtained;
step S102, constructing task data corresponding to the mapping record based on the JAVA reflection technology, and storing the task data into a task data table;
and step S103, scanning the task data table by utilizing the predefined classes, acquiring the data of the task to be executed, and processing the data of the task to be executed.
The mapping relationship table records the mapping relationship between the service type and the task type, and may include: the mapping table comprises a mapping identification field, a service data source field, a task type field, a task initial state field and a service type field, which are shown in the structure of the mapping relation table in table 1. Wherein, Id represents a mapping identification field and represents the unique identification of the mapping list; the rfFiledName represents a service data source field, the field is a dynamic field, and a source of service data required by executing a task can be inquired through the field, for example, a link for calling an agent service to recharge in a virtual service requires an order number, the corresponding rfFiledName can be the order number, and for example, when the recharging fails and the user needs to be refunded, the corresponding rfFiledName can be the refunded order number; worktype represents a task type field, such as a top up task; init _ status represents an initial state field of a task, such as a cost recharging service of a virtual service, and after a user successfully recharges, the initial state is waiting for recharging; biz _ type indicates a service type field such as a fee charging service in a virtual service.
Name of field Type (B) Note Whether a field is dynamic
Id String Mapping identification Whether or not
rfFiledName String Required service data source field names Is that
workerType Integer Task type Whether or not
Init_tatus Integer Initial state of task Whether or not
Biz_type String Corresponding service type Whether or not
TABLE 1 Structure of mapping relationship table
In the task processing method of the embodiment of the invention, when the system runs, the data is inquired from the mapping relation table on the reserved expansion point by taking the service type as the inquiry condition. The reserved extension point refers to an extension interface reserved in the host node during system design, for example, when a user purchases an item on an e-commerce platform, and after payment is successful, the item is in a state of waiting for delivery, and the delivery state can be regarded as the reserved extension point. If the inquired data is empty, it indicates that there is no mapping record corresponding to the service type, i.e. there is no task corresponding to the service to be executed, and at this time, there is no need to perform the next link, and the process is terminated, otherwise, a piece of task data can be constructed by the JAVA reflection technology and stored in the task data table. For example, in an offline service such as refueling, after the user successfully pays, the user can refuel to an offline appointed store, only order information needs to be displayed to the staff of the opposite side, and a driving system does not need to call a service interface of an agent, so that a corresponding task cannot be read. If the virtual business is telephone fee recharging, flow recharging and the like, after the user finishes payment, the system is required to be driven to call a service interface of an agent, the mapping record can be read from the mapping relation table according to the business type, and the business such as telephone fee recharging, flow recharging and the like needs to store a piece of task data for driving the system to execute the task, so that the corresponding task data of the mapping record is required to be constructed after the mapping record is generated.
Because the service data source field in the mapping relation table is a dynamic field, the inquired mapping record comprises the dynamic field, so that specific service data can be dynamically acquired through a JAVA reflection technology, then task data corresponding to the mapping record is constructed according to the acquired specific service data, and the constructed task data is added to the task data table. Table 2 is a structure of a task data table, and task data may include: the task type, the current state of the task, and the identification of the associated business data may also include task identification. As shown in table 2, id represents a task identifier, and represents a unique identifier of a task, such as a task sequence number; the rfId represents an identifier of associated service data, that is, service data required for executing the task can be obtained by the rfId, for example, a link for calling agent service to recharge is driven in the virtual service, when the recharge task is executed, the required service data are all in an order table, and the rfId is associated with the service data by the rfId, so that the rfId can be an order number corresponding to the specific service data or other identifiers capable of being associated with the service data; the workType represents a task type; status represents the current state of the task, such as the waiting-to-recharge state, the ongoing recharge state, the successful recharge state and the failed recharge state in the recharge task.
Name of field Type (B) Remarks for note
id Integer Task identification
rfId Integer Identification of associated business data
workerType Integer Task type
status Integer Task current state
TABLE 2 Structure of task data Table
The task data may include: the task type, the current state of the task and the identification of the associated service data are stored, and the generated task data are stored in the task data table, so that the task data table can be scanned, whether the task needs to be executed or not is judged according to the task type and the current state of the task, and then the data needed by the task are acquired according to the identification of the associated service data, so that the task can be executed. In the embodiment of the invention, the task data table can be scanned by utilizing the predefined classes to acquire the data of the task to be executed and process the data of the task to be executed. The class is a prototype of a certain type of object definition variable and method, represents abstraction of a kind of things with common characteristics in real life, and is the basis of object-oriented programming.
In the technical scheme of the task processing of the embodiment of the invention, the mapping relation table can be inquired through the service type, the mapping relation table records the mapping relation between the service type and the task type, so that after the mapping record is generated, the task data corresponding to the mapping record can be constructed according to the generated mapping record, then the task data is added into the task data table, so that the data corresponding to the task to be executed can be obtained by scanning the task data table, then, the predefined class scanning task data table is used for acquiring and processing the task data to be executed, thereby solving the problems that the reusability of class files is reduced due to the coupling of three steps of operations in the prior art, and each new task needs to develop the function of scanning the database to inquire data, and the flexibility and maintainability of the code can be improved.
The mapping relation table is an important part of the task processing method in the embodiment of the invention, and task data can be constructed by the mapping relation table to execute the task. In a referential embodiment of the present invention, the task processing method may further include: acquiring input data through a visual interface, generating a mapping record between a service type and a task type corresponding to the input data, and storing the generated mapping record into a mapping relation table.
A user can input data through a visual interface, such as a user recharging service, inputs a recharging amount and a recharging number on the visual interface, then generates a mapping record between a service type and a task type corresponding to the input data, and finally stores the generated mapping record into a mapping relation table, such as a telephone fee recharging service, after the user pays successfully, a mapping record is added in the mapping relation table, and the table 3 is the mapping record of the service type and the task type. In table 3, the mapping identifier Id of the mapping record is 1001; the service data source rfFiledName is order.or derId, and specific service data can be obtained from the field orderId of the table Order by a JAVA reflection technology; the task type is 1, which represents a recharging task; the initial state Init _ status of the task is 1, which represents waiting for recharging; the service type Biz _ type is Recharge, which represents a Recharge service.
Figure BDA0002615937400000111
TABLE 3 mapping record of service type and task type
In addition to adding the mapping record to the mapping relationship table, the mapping record may also be deleted from the mapping relationship table according to a requirement, and therefore in a referential embodiment of the present invention, the task processing method may further include: and after receiving the task canceling request, deleting the mapping record corresponding to the task canceling request from the mapping relation table. The task canceling request is that the specific task canceling request includes a specific task to be canceled, the mapping record to be deleted can be obtained according to the task canceling request, and the mapping record is deleted from the mapping relation table.
It can be seen that, in the embodiment of the present invention, a mapping record may be dynamically added or deleted through the mapping relationship table, so that task data corresponding to the mapping record may be dynamically added or deleted, and a technical problem that a task cannot be dynamically terminated or newly added in a process of flow arrangement in the prior art is solved.
After querying the mapping relationship table by using the service type as a query condition to obtain a mapping record corresponding to the service type, task data corresponding to the mapping record may be constructed, so in a referential embodiment of the present invention, constructing the task data corresponding to the mapping record based on a JAVA reflection technology may include: acquiring a task type in the mapping record; traversing the mapping record, and determining a dynamic field in the mapping record; based on JAVA reflection technology, acquiring service data corresponding to the mapping record according to the dynamic field; and constructing the task data corresponding to the mapping record according to the service data corresponding to the mapping record and the task type in the mapping record.
Because the mapping record has a dynamic field configuration, when constructing the task data, the JAVA reflection technology needs to be used to obtain specific service data according to the dynamic field. In the running state, for any entity class, all the attributes and methods of the class can be known; for any object, any method and attribute of the object can be called; this function of dynamically acquiring information and dynamically calling object methods is called the reflection technique of the JAVA language. Specifically, after a mapping record corresponding to the service type a is queried from the mapping relation table, a task type B in the mapping record is obtained; traversing the mapping record, determining a dynamic field in the mapping record, and reading a dynamic field value; because the dynamic field value can be represented in the form of a separator, such as Order, the Order is analyzed by JAVA reflection technology, the field Order id of which the source of the service data is table Order is obtained, and then the service data is analyzed, such as obtaining the service data: recharging 50 yuan for the number 130 XXXX; and finally, constructing task data corresponding to the mapping record according to the analyzed service data and the task type in the mapping record.
In the embodiment of the invention, the task data table can be scanned by utilizing the predefined classes to acquire the data of the task to be executed and process the data of the task to be executed. Therefore, it is necessary to define a class in advance, define a specific execution method in the class, call the defined specific execution method, scan the task data table to obtain task data to be executed, and finally process the task data to be executed. Therefore, in a referential embodiment of the present invention, the method for processing the task may further include: defining an abstract class, defining a compiling task model method, a compiling task distribution method and a scanning method in the abstract class, and defining a first global variable and a second global variable, wherein the first global variable is a task model type, and the second global variable is a task distribution type; defining a task model class, and defining a task type variable and a task execution logic in the task model class; defining a task distribution interface class, defining a task distribution method in the task distribution interface class, and defining a task operation global variable of a task operation type; defining a task operation class, and defining a task locking method, an operation executing method and a task unlocking method in the task operation class; defining a task execution class, inheriting the abstract class by the task execution class, and defining a timing execution method in the task execution class.
Fig. 2 is a predefined class structure diagram according to an embodiment of the present invention. As can be seen from fig. 2, the predefined classes in the embodiment of the present invention include: the task model class, the abstract class, the task execution class, the task distribution interface class and the task operation class, and variables and methods defined in the classes are described in detail below.
Defining a task model class, which can be represented by a WorkerModel, and defining the WorkerModel by using a POJO class (namely a simple entity class, wherein the POJO class has the function of facilitating a programmer to use a data table in a database, can conveniently use the POJO class as an object, and can also conveniently call a get method and a set method of the POJO class). In the WorkerModel, two member variables are defined: a task type variable, i.e., an Integer type of workType; task execution logic, String type workhandler. The workflow type represents a task type variable to be scanned, and if the workflow type is 1, the workflow type represents a recharging task; the workhandler represents a class instance that performs task logic, such as performing load task logic.
An abstract class is defined, which can be expressed as abstract ScanWorker, and is equivalent to loading a driver of a task to be executed. In Abstract ScanWorker, the following abstraction methods are defined: compiling a task model method, which can be represented by buildWorkerModel; compiling a task distribution method which can be expressed by buildWorkerDespatcher; the scanning method with specific logic can be represented by start Scan. In addition, in AbstractScanWorker, two global member variables are also defined: a first global variable, namely a variable WorkerModel of WorkerModel type; the second global variable, the variable worerdesispatcher of the iwordesispatcher type.
The task execution class is defined and can be represented by Worker, such as Rec hargeWorker, which executes the telephone charge recharging logic. It should be noted that, the task execution class Worker inherits and loads the abstract class abstract scan Worker, so as to implement the abstract methods buildwerModel and buildwerDespatcher defined in the abstract scan Worker, and the Worker may also define the methods belonging to the Worker: the method is executed regularly and is denoted by DoWorker.
Considering that an abstract class is a class that cannot be instantiated, the abstract methods defined in the abstract class need only be declared and need not be implemented. Therefore, in the embodiment of the present invention, the Worker inherits the abstract scanner, and constructs a WorkerModel instance representing a specific task class inside the realized abstract workbench model, for example, for a recharging task type, constructs a rechargeWorkerModel instance, where the worketype of the instance is set to rechargeWorkerType, and the executive identifier handleberwaid is set to rechargehandleberbean. In addition, a timer annotation jd-task-annotation can be added to the dowker method for timing the execution of the dowker. And calling a method startScan of a parent class (namely, AbstractScanWorker) in the DoWorker method to load the task to be executed. Therefore, in a referential embodiment of the present invention, invoking the scanning method defined in the abstract class may include: and calling a timing execution method defined in the task execution class, and calling a scanning method defined in the abstract class in a timing mode inside the timing execution method.
A task distribution interface class is defined and can be represented by an IworerDeispatcher, and in the IworerDei dispatcher, a task distribution method is defined and represented by the worerDeispatccher. A default implementation class, denoted MultiThreadWorkerDespatcher, is provided for providing thread pool-based multi-threaded concurrently executing task data. In iwordesichecker, global variables are also defined: a variable WorkerProcessor of the WorkerProcessor type.
Defining a task operation class, which can be represented by a WorkerProcessor, wherein three implementation methods are defined: a locking task method, which is expressed by lockWorker; executing an operation method, represented by a doProcessor; and (4) an unlocking task method, which is expressed by unlockWorker.
In addition, in the embodiment of the present invention, a Task record class may also be defined, which is represented by Task, and a member variable is defined in the T ask: integer type workerType, which indicates the Task type to which Task belongs; and Integer type status, indicating the Task state. For example, in the recharge task, the workerType is 1, which represents the recharge task; status is 1, indicating waiting for recharge. Worker scans the task data table conditioned on the workerType and status at runtime.
In a referential embodiment of the present invention, scanning the task data table by using a predefined class to obtain task data to be executed, and processing the task data to be executed may include: calling a compiling task model method and a compiling task distribution method defined in the abstract class through the task execution class, and assigning values to a first global variable and a second global variable which are defined; calling a scanning method defined in the abstract class, reading a task type variable defined in the task model class, scanning a task data table according to the task type variable, and acquiring task data to be executed; and calling a task distribution method defined in the task distribution interface class, and processing the data of the task to be executed according to the task execution logic defined in the task model class.
When the AbstractScanWorker is started, the Worker inheriting the AbstractScanWorker can call a buildWorkerModel method defined in the AbstractScanWorker and assign a global variable workerModel, so that a specific workerModel object can be obtained, and the w-orderModel object comprises a workerType and a workerHandler. For example, a concrete recharging worker for executing the telephone charge recharging task inherits the abstract scanner worker, and can realize a b uildWorkerModel method to obtain a corresponding recharging model object, namely, a recharging task type and a recharging task logic corresponding to the assignment recharging telephone charge task. Worker can also call buildWorkerDespatcher method defined in Abstract ScanWorker, and assign a value to the global variable worerDespatcher.
The Worker can call a startScan method defined in the AbstractScan Worker to read the workerType in the wo rkerMode object and query the task data which is in accordance with the task type from the task data table as a query condition, namely the task data to be executed. In a referential embodiment of the present invention, scanning the task data table according to the task type variable to obtain the task data to be executed may include: inquiring the task data table by taking the task type variable as an inquiry condition, and judging whether optional task data corresponding to the task type variable exists in the task data table; if yes, judging whether the task state of the optional task data is waiting for processing, and if yes, determining the optional task data as the task data to be executed.
After determining the data of the task to be executed, calling a word kernel dispatcher method defined in the task distribution interface class, and processing the data of the task to be executed according to the task execution logic in the word Mode object. In a referential embodiment of the present invention, invoking a task distribution method defined in a task distribution interface class, and processing data of a task to be executed according to a task execution logic defined in a task model class may include: determining a target task type corresponding to task data to be executed, and calling a task distribution method to check whether a thread pool corresponding to the target task type exists in a thread pool container; if the task exists, processing the data of the task to be executed according to the task execution logic by using the thread pool corresponding to the target task type; and if the target task type does not exist, constructing a thread pool corresponding to the target task type, putting the thread pool corresponding to the target task type into a thread pool container, and processing the data of the task to be executed according to the task execution logic by using the thread pool corresponding to the target task type.
Specifically, the inquired data of the task to be executed and the workermodel object are sent to the wo rkerdiscatccher, and the workerdiscatccher firstly checks whether a thread pool corresponding to the target task type exists in the threadpool container ThreadPoolMap, that is, checks whether a thread pool with the workerType as the key exists in the ThreadPoolMap. If the thread pool does not exist, a thread pool is created, a threadPoolMap is put in, the worerType is taken as a key, and then the created thread pool is used for carrying out asynchronous execution of data; if so, the thread pool is used to asynchronously execute data.
In a referential embodiment of the present invention, processing data of a task to be executed according to a task execution logic by using a thread pool corresponding to a target task type may include: reading an empty thread in a thread pool corresponding to the target task type, and instantiating a task operation class according to task data to be executed and task execution logic through the empty thread; calling a task locking method defined in a task operation class, and updating a task state of task data to be executed stored in a task data table into a locking state; calling an execution operation method defined in the task operation class, processing the data of the task to be executed according to the task execution logic, and acquiring a processing result; and calling an unlocking task method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table to finish unlocking.
The thread pool will read out the idle thread first, and the execution logic of the thread sends the data to be executed and the workerModel object to the WorkerProcess. After the WorkerProcess obtains the data, the following steps are executed: calling a lockWorker method defined in the WorkerProcess, updating the task state of the to-be-executed task data stored in the task data table to be a locked state, namely locking the to-be-executed task data, and updating the task state of the to-be-executed task data in the task data table to be the locked state to represent that the to-be-executed task data is being executed; calling a doProcessor method defined in the WorkerProcesses, processing the data of the task to be executed according to the WorkerHandler, acquiring a processing result, and acquiring the WorkerHandle from a WorkerModel object, wherein the processing structure can comprise processing success and processing failure; and calling an unlockWorker method defined in the WorkerProcess, updating the task state of the to-be-executed task data stored in the task data table, and unlocking.
According to the technical scheme of the task processing of the embodiment of the invention, the mapping relation table can be inquired through the service type, the mapping relation table records the mapping relation between the service type and the task type, so that after the mapping record is generated, the task data corresponding to the mapping record can be constructed according to the generated mapping record, then the task data is added into the task data table, so that the data corresponding to the task to be executed can be obtained by scanning the task data table, then, the predefined class scanning task data table is used for acquiring and processing the task data to be executed, thereby solving the problems that the reusability of class files is reduced due to the coupling of three steps of operations in the prior art, and each new task needs to develop the function of scanning the database to inquire data, and the flexibility and maintainability of the code can be improved.
Fig. 3 is a schematic diagram of main blocks of a task processing device according to an embodiment of the present invention. As shown in fig. 3, the main modules of the task processing device 300 may include: a query module 301, a construction module 302, and a processing module 303.
The query module 301 may be configured to query the mapping relationship table using the service type as a query condition, and obtain a mapping record corresponding to the service type; the constructing module 302 may be configured to construct task data corresponding to the mapping record based on a JAVA reflection technology, and store the task data into a task data table; the processing module 303 may be configured to scan the task data table by using a predefined class, acquire task data to be executed, and process the task data to be executed. The mapping relation table records the mapping relation between the service type and the task type.
In this embodiment of the present invention, the mapping relationship table may include: the mapping system comprises a mapping identification field, a service data source field, a task type field, a task initial state field and a service type field. The task processing device 300 may further include: a generating module (not shown in the figures) operable to: acquiring input data through a visual interface, generating a mapping record between a service type and a task type corresponding to the input data, and storing the generated mapping record into a mapping relation table; and after receiving the task canceling request, deleting the mapping record corresponding to the task canceling request from the mapping relation table.
In this embodiment of the present invention, the constructing module 302 may further be configured to: acquiring a task type in the mapping record; traversing the mapping record, and determining a dynamic field in the mapping record; based on JAVA reflection technology, acquiring service data corresponding to the mapping record according to the dynamic field; and constructing the task data corresponding to the mapping record according to the service data corresponding to the mapping record and the task type in the mapping record. The task data may include: task type, task current state, and identification of associated business data.
Optionally, the task processing device 300 may further include: a definition module (not shown) operable to: defining an abstract class, defining a compiling task model method, a compiling task distribution method and a scanning method in the abstract class, and defining a first global variable and a second global variable, wherein the first global variable is a task model type, and the second global variable is a task distribution type; defining a task model class, and defining a task type variable and a task execution logic in the task model class; defining a task distribution interface class, defining a task distribution method in the task distribution interface class, and defining a task operation global variable of a task operation type; defining a task operation class, and defining a task locking method, an operation executing method and a task unlocking method in the task operation class; defining a task execution class, inheriting the abstract class by the task execution class, and defining a timing execution method in the task execution class.
In this embodiment of the present invention, the processing module 303 may further be configured to: calling a compiling task model method and a compiling task distribution method defined in the abstract class through the task execution class, and assigning values to a first global variable and a second global variable which are defined; calling a scanning method defined in the abstract class, reading a task type variable defined in the task model class, scanning a task data table according to the task type variable, and acquiring task data to be executed; and calling a task distribution method defined in the task distribution interface class, and processing the data of the task to be executed according to the task execution logic defined in the task model class.
In this embodiment of the present invention, the processing module 303 may further be configured to: inquiring the task data table by taking the task type variable as an inquiry condition, and judging whether optional task data corresponding to the task type variable exists in the task data table; if yes, judging whether the task state of the optional task data is waiting for processing, and if yes, determining the optional task data as the task data to be executed.
In this embodiment of the present invention, the processing module 303 may further be configured to: determining a target task type corresponding to task data to be executed, and calling a task distribution method to check whether a thread pool corresponding to the target task type exists in a thread pool container; if the task exists, processing the data of the task to be executed according to the task execution logic by using the thread pool corresponding to the target task type; and if the target task type does not exist, constructing a thread pool corresponding to the target task type, putting the thread pool corresponding to the target task type into a thread pool container, and processing the data of the task to be executed according to the task execution logic by using the thread pool corresponding to the target task type.
In this embodiment of the present invention, the processing module 303 may further be configured to: reading an empty thread in a thread pool corresponding to the target task type, and instantiating a task operation class according to task data to be executed and task execution logic through the empty thread; calling a task locking method defined in a task operation class, and updating a task state of task data to be executed stored in a task data table into a locking state; calling an execution operation method defined in the task operation class, processing the data of the task to be executed according to the task execution logic, and acquiring a processing result; and calling an unlocking task method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table to finish unlocking.
In this embodiment of the present invention, the processing module 303 may further be configured to: and calling a timing execution method defined in the task execution class, and calling a scanning method defined in the abstract class in a timing mode inside the timing execution method.
As can be seen from the above description, the task processing device of the embodiment of the present invention can query the mapping relation table by the service type, the mapping relation table records the mapping relation between the service type and the task type, so that after the mapping record is generated, the task data corresponding to the mapping record can be constructed according to the generated mapping record, then the task data is added into the task data table, so that the data corresponding to the task to be executed can be obtained by scanning the task data table, then, the predefined class scanning task data table is used for acquiring and processing the task data to be executed, thereby solving the problems that the reusability of class files is reduced due to the coupling of three steps of operations in the prior art, and each new task needs to develop the function of scanning the database to inquire data, and the flexibility and maintainability of the code can be improved.
Fig. 4 shows an exemplary system architecture 400 of a task processing method or a task processing device to which an embodiment of the present invention can be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the task processing method provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the task processing device is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a query module, a construction module, and a processing module. The names of the modules do not limit the modules themselves under certain circumstances, for example, the query module may also be described as a module that queries the mapping relation table by using the service type as a query condition to obtain the mapping record corresponding to the service type.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: inquiring a mapping relation table by taking the service type as an inquiry condition to obtain a mapping record corresponding to the service type, wherein the mapping relation table records the mapping relation between the service type and the task type; constructing corresponding task data of the mapping record based on a JAVA reflection technology, and storing the task data into a task data table; and scanning the task data table by utilizing the predefined classes, acquiring the data of the task to be executed, and processing the data of the task to be executed.
According to the technical scheme of the embodiment of the invention, the mapping relation table can be inquired through the service type, the mapping relation between the service type and the task type is recorded in the mapping relation table, so that after the mapping record is generated, the task data corresponding to the mapping record can be constructed according to the generated mapping record, then the task data is added into the task data table, and thus the data corresponding to the task to be executed can be obtained through scanning the task data table, and then the task data to be executed is obtained and processed by utilizing the predefined class scanning task data table.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A task processing method, comprising:
inquiring a mapping relation table by taking the service type as an inquiry condition to obtain a mapping record corresponding to the service type, wherein the mapping relation table records the mapping relation between the service type and the task type;
constructing task data corresponding to the mapping record based on a JAVA reflection technology, and storing the task data into a task data table;
and scanning the task data table by utilizing a predefined class, acquiring task data to be executed, and processing the task data to be executed.
2. The method of claim 1, wherein the mapping relationship table comprises: mapping identification fields, service data source fields, task type fields, task initial state fields and service type fields; the method further comprises the following steps:
acquiring input data through a visual interface, generating a mapping record between a service type and a task type corresponding to the input data, and storing the generated mapping record into the mapping relation table; and
and after receiving a task canceling request, deleting the mapping record corresponding to the task canceling request from the mapping relation table.
3. The method of claim 1, wherein constructing the task data corresponding to the mapping record based on the JAVA reflection technology comprises:
acquiring the task type in the mapping record;
traversing the mapping record, and determining a dynamic field in the mapping record;
based on JAVA reflection technology, acquiring the service data corresponding to the mapping record according to the dynamic field;
constructing task data corresponding to the mapping record according to the service data corresponding to the mapping record and the task type in the mapping record; wherein the task data comprises: task type, task current state, and identification of associated business data.
4. The method of claim 1, further comprising:
defining an abstract class, defining a compiling task model method, a compiling task distribution method and a scanning method in the abstract class, and defining a first global variable and a second global variable, wherein the first global variable is a task model type, and the second global variable is a task distribution type;
defining a task model class, and defining a task type variable and a task execution logic in the task model class;
defining a task distribution interface class, defining a task distribution method in the task distribution interface class, and defining a task operation global variable of a task operation type;
defining a task operation class, and defining a task locking method, an operation executing method and a task unlocking method in the task operation class;
and defining a task execution class, wherein the task execution class inherits the abstract class, and a timing execution method is defined in the task execution class.
5. The method according to claim 4, wherein the scanning the task data table by using the predefined class to obtain task data to be executed, and processing the task data to be executed comprises:
calling the compiling task model method and the compiling task distribution method defined in the abstract class through the task execution class to assign values to the first global variable and the second global variable which are defined;
calling the scanning method defined in the abstract class, reading the task type variable defined in the task model class, scanning the task data table according to the task type variable, and acquiring the task data to be executed;
and calling the task distribution method defined in the task distribution interface class, and processing the task data to be executed according to the task execution logic defined in the task model class.
6. The method according to claim 5, wherein the scanning the task data table according to the task type variable to obtain task data to be executed comprises:
inquiring the task data table by taking the task type variable as an inquiry condition, and judging whether optional task data corresponding to the task type variable exists in the task data table;
if yes, judging whether the task state of the optional task data is waiting for processing, and if yes, determining that the optional task data is the task data to be executed.
7. The method according to claim 5, wherein the invoking the task distribution method defined in the task distribution interface class and processing the task data to be executed according to the task execution logic defined in the task model class includes:
determining a target task type corresponding to the to-be-executed task data, and calling the task distribution method to check whether a thread pool corresponding to the target task type exists in a thread pool container;
if yes, processing the task data to be executed according to the task execution logic by using a thread pool corresponding to the target task type;
and if the target task type does not exist, establishing a thread pool corresponding to the target task type, putting the thread pool corresponding to the target task type into the thread pool container, and processing the task data to be executed according to the task execution logic by using the thread pool corresponding to the target task type.
8. The method according to claim 7, wherein the processing the task data to be executed according to the task execution logic by using the thread pool corresponding to the target task type includes:
reading an empty thread in a thread pool corresponding to the target task type, and instantiating the task operation class according to the task data to be executed and the task execution logic through the empty thread;
calling the task locking method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table into a locking state;
calling the execution operation method defined in the task operation class, and processing the task data to be executed according to the task execution logic to obtain a processing result;
and calling the unlocking task method defined in the task operation class, and updating the task state of the to-be-executed task data stored in the task data table to finish unlocking.
9. The method of claim 5, wherein said invoking said scan method defined in said abstract class comprises:
and calling a timing execution method defined in the task execution class, and calling the scanning method defined in the abstract class in a timing mode inside the timing execution method.
10. A task processing apparatus, comprising:
the query module is used for querying a mapping relation table by taking the service type as a query condition to obtain a mapping record corresponding to the service type, and the mapping relation table records the mapping relation between the service type and the task type;
the construction module is used for constructing the task data corresponding to the mapping record based on a JAVA reflection technology and storing the task data into a task data table;
and the processing module is used for scanning the task data table by utilizing a predefined class, acquiring task data to be executed and processing the task data to be executed.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202010769278.0A 2020-08-03 2020-08-03 Task processing method and task processing device Pending CN113760486A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010769278.0A CN113760486A (en) 2020-08-03 2020-08-03 Task processing method and task processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010769278.0A CN113760486A (en) 2020-08-03 2020-08-03 Task processing method and task processing device

Publications (1)

Publication Number Publication Date
CN113760486A true CN113760486A (en) 2021-12-07

Family

ID=78785657

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010769278.0A Pending CN113760486A (en) 2020-08-03 2020-08-03 Task processing method and task processing device

Country Status (1)

Country Link
CN (1) CN113760486A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060288018A1 (en) * 2005-06-20 2006-12-21 Afshan Ally Loose coupling of Web services
US8874621B1 (en) * 2011-10-09 2014-10-28 LockPath, Inc. Dynamic content systems and methods
CN107273138A (en) * 2017-07-04 2017-10-20 杭州铜板街互联网金融信息服务有限公司 Decoupling method and system based on interaction between Android business modules
CN109471711A (en) * 2018-11-12 2019-03-15 中国银行股份有限公司 A kind of method and device of task processing
CN110716748A (en) * 2019-09-24 2020-01-21 深圳中集智能科技有限公司 Service processing method and device, computer readable medium and electronic equipment
CN110750553A (en) * 2019-09-02 2020-02-04 成都市知用科技有限公司 Method for self-defining export of data in service management system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060288018A1 (en) * 2005-06-20 2006-12-21 Afshan Ally Loose coupling of Web services
US8874621B1 (en) * 2011-10-09 2014-10-28 LockPath, Inc. Dynamic content systems and methods
CN107273138A (en) * 2017-07-04 2017-10-20 杭州铜板街互联网金融信息服务有限公司 Decoupling method and system based on interaction between Android business modules
CN109471711A (en) * 2018-11-12 2019-03-15 中国银行股份有限公司 A kind of method and device of task processing
CN110750553A (en) * 2019-09-02 2020-02-04 成都市知用科技有限公司 Method for self-defining export of data in service management system
CN110716748A (en) * 2019-09-24 2020-01-21 深圳中集智能科技有限公司 Service processing method and device, computer readable medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN108920222B (en) Business processing method and device based on rule engine
US20130132296A1 (en) Networked business object sharing
CN110473036B (en) Method and device for generating order number
CN111400061A (en) Data processing method and system
CN110019330B (en) Information output method and device
CN111427971B (en) Business modeling method, device, system and medium for computer system
CN110706093A (en) Accounting processing method and device
CN113971037A (en) Application processing method and device, electronic equipment and storage medium
CN113076153A (en) Interface calling method and device
CN111126948A (en) Processing method and device for approval process
US9760841B2 (en) ABAP Unified connectivity
CN113672671B (en) Method and device for realizing data processing
CN113448570A (en) Data processing method and device, electronic equipment and storage medium
US11016830B2 (en) Entity-based service operation for object-based persistence
CN113760486A (en) Task processing method and task processing device
CN112650598B (en) Multi-application access method for workflow system
CN113760969A (en) Data query method and device based on elastic search
CN113762835A (en) Method and device for processing order data
CN113222680A (en) Method and device for generating order
CN112651536A (en) Method and device for determining delivery address
CN113077201B (en) Method, device and system for analyzing service parameters
US20230049322A1 (en) Information processing method, device, system, and computer-readable storage medium
CN116883109A (en) Service processing method, device, electronic equipment and computer readable medium
CN114297999A (en) Product generation method and device, electronic equipment and storage medium
US10831534B2 (en) Mainframe data flow optimization for data integration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination