Disclosure of Invention
The invention aims to provide a decoupling method based on configuration of an instant trigger task, and aims to solve the problem of decoupling method, system and device based on configuration of the instant trigger task.
The embodiment of the invention provides a decoupling method based on configuration instant trigger tasks, which comprises the following steps:
s1, adding an entity metadata table and a field metadata table, and performing addition, deletion and modification operations on a database based on unified DAO according to mapping relations stored in the entity metadata table and the field metadata table to obtain modified data;
s2, the DAO sends the information with the same format as the modified data to an information queue;
s3, abstracting different business behaviors into general actions, and adding an action table, wherein the action table comprises a plurality of action types and implementation classes corresponding to the action types;
s4, adding a task table, wherein the data of the trigger task accords with the columns of screening conditions, executing actions, starting and stopping, serial numbers and the like, and when the message is consumed, finding a plurality of pieces of data in the corresponding action table in the task table, and sequentially executing the data according to the sequence;
s5, adding message queue consumption service, triggering a task list according to the content of the message, acquiring a corresponding task list, sequentially judging whether the current service data accords with screening conditions configured on the task, and acquiring a corresponding implementation class from the task list according to the action type to execute the action if the current service data accords with the screening conditions.
The invention also provides a decoupling system based on the configuration instant triggering task, which comprises:
the adding, deleting and modifying module is used for adding the entity metadata table and the field metadata table, and based on unified DAO, adding, deleting and modifying the database according to the mapping relation stored in the entity metadata table and the field metadata table to obtain modified data;
the sending module is used for sending the message with the same format as the modified data to the message queue by the DAO;
the action table module: the method comprises the steps of abstracting different business behaviors into general actions, and adding an action table, wherein the action table comprises a plurality of action types and implementation classes corresponding to the action types;
the task table module: the data used for adding the task list and triggering the task accords with the columns of screening conditions, executing actions, starting and stopping, serial numbers and the like, and when the message is consumed, a plurality of pieces of data in the corresponding action list are found in the task list and are sequentially executed according to the sequence;
message queue consumption service module: and the message queue consumption service is used for adding a message, triggering a task list according to the content of the message, acquiring a corresponding task list, sequentially judging whether the current service data accords with screening conditions configured on the task, and acquiring a corresponding implementation class from the action list according to the action type to execute the action if the current service data accords with the screening conditions.
The embodiment of the invention also provides a decoupling device based on configuration instant triggering task, which comprises: a memory, a processor and a computer program stored on the memory and executable on the processor, which when executed by the processor, performs the steps of the method described above.
The embodiment of the invention also provides a computer readable storage medium, wherein the computer readable storage medium stores an information transmission implementation program, and the program realizes the steps of the method when being executed by a processor.
By adopting the embodiment of the invention, the decoupling of the task is triggered immediately based on configuration.
The foregoing description is only an overview of the present invention, and is intended to provide a more clear understanding of the technical means of the present invention, as it is embodied in accordance with the present invention, and to make the above and other objects, features and advantages of the present invention more apparent, as it is embodied in the following detailed description of the invention.
Detailed Description
The technical solutions of the present invention will be clearly and completely described in connection with the embodiments, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Method embodiment
According to an embodiment of the present invention, a decoupling method based on configuration of an instant trigger task is provided, and fig. 1 is a flowchart of a decoupling method based on configuration of an instant trigger task according to an embodiment of the present invention, as shown in fig. 1, and specifically includes:
s1, adding an entity metadata table and a field metadata table, and performing addition, deletion and modification operations on a database based on unified DAO according to mapping relations stored in the entity metadata table and the field metadata table to obtain modified data;
s1 specifically comprises: the entity metadata table is used for defining the mapping relation between different service entities and the database table, the field metadata table is used for defining the types of fields, the basic attributes of the fields and the mapping relation between the fields and the database column, unified service object classes are added, the entity names and the key value pair sets of the fields are contained, and based on unified DAO, the database is subjected to adding, deleting and modifying operations through the mapping relation stored in the two metadata tables.
S2, the DAO sends the information with the same format as the modified data to an information queue;
s2 specifically comprises: after the DAO adds and deletes the service data, the message with the same format is sent to the same message queue, and the message content comprises: operator, operation time, operation end, operation type, operation object, operation data, and other information.
S3, abstracting different business behaviors into general actions, and adding an action table, wherein the action table comprises a plurality of action types and implementation classes corresponding to the action types;
s4, adding a task table, wherein the data of the trigger task accords with the columns of screening conditions, executing actions, starting and stopping, serial numbers and the like, and when the message is consumed, finding a plurality of pieces of data in the corresponding action table in the task table, and sequentially executing the data according to the sequence;
s4 specifically comprises the following steps: adding a task list, including task names, execution objects and trigger occasions, wherein the execution data need to meet the screening conditions, execution actions, start and stop, serial numbers and other columns, and finding out a plurality of pieces of data in the corresponding action list in the task list when the data operation message is consumed, and sequentially executing the data according to the sequence.
S5, adding message queue consumption service, triggering a task list according to the content of the message, acquiring a corresponding task list, sequentially judging whether the current service data accords with screening conditions configured on the task, and acquiring a corresponding implementation class from the task list according to the action type to execute the action if the current service data accords with the screening conditions.
The specific implementation method is as follows:
FIG. 2 is a specific flow chart of a decoupling method based on configuring an instant trigger task according to an embodiment of the present invention;
1. two metadata definition tables are added: the entity metadata table is used for defining the mapping relation between different business entities and the database table, and the field metadata table is used for defining the types of the fields, the basic attributes of the fields and the mapping relation between the fields and the database column. And adding unified BO, wherein the unified BO comprises a key value pair set of entity names and fields, and adding, deleting and modifying the database by using the unified DAO through the mapping relation stored in the two metadata tables.
2. After the DAO adds and deletes the service data, the message with the same format is sent to the same message queue, and the message content comprises: the operator, the operation time, the operation end (app, web), the operation type (add, delete, change), the operation object (order, contract, etc.), the operation data (newly added data, deleted data, changed field value), other information (operation trigger, prevent loop triggering).
3. Adding an action table abstracts different business behaviors into actions, for example: business actions such as sending notification, field change, data locking, submitting approval and the like are abstracted into general actions, and special business logic of a client is abstracted into special actions. All types of actions implement a unified interface, registering all types of actions for invocation at the start of the queue consumption service.
4. The instant trigger task list is added, which comprises the task name, the execution object, the trigger time (adding, deleting and changing), the screening condition which the execution data needs to meet, the execution action, the start and stop, the serial number and the like. When the data manipulation message is consumed, a corresponding action list can be found in the table, which is sequentially executed in order.
5. And adding a message queue consumption service, namely immediately triggering a task list according to the operation type and the operation object acquired by analyzing the message content to acquire a corresponding task list, sequentially judging whether the current service data accords with screening conditions configured on the task, and acquiring a corresponding action executor from an action execution pool according to the action type to execute the action if the current service data accords with the screening conditions.
The beneficial effects are that: the invention does not need customized software, modifies the corresponding branch code without changing the business of the customer, and reduces the research, development and maintenance cost.
System embodiment
According to an embodiment of the present invention, a decoupling system based on configuration of an instant trigger task is provided, and fig. 3 is a schematic diagram of a decoupling system based on configuration of an instant trigger task according to an embodiment of the present invention, as shown in fig. 3, and specifically includes:
the adding, deleting and modifying module is used for adding the entity metadata table and the field metadata table, and based on unified DAO, adding, deleting and modifying the database according to the mapping relation stored in the entity metadata table and the field metadata table to obtain modified data;
the adding and deleting module is specifically used for: the entity metadata table is used for defining the mapping relation between different service entities and the database table, the field metadata table is used for defining the types of fields, the basic attributes of the fields and the mapping relation between the fields and the database column, unified service object classes are added, the entity names and the key value pair sets of the fields are contained, and based on unified DAO, the database is subjected to adding, deleting and modifying operations through the mapping relation stored in the two metadata tables.
The sending module is used for sending the message with the same format as the modified data to the message queue by the DAO;
the sending module is specifically used for: after the DAO adds and deletes the service data, the message with the same format is sent to the same message queue, and the message content comprises: operator, operation time, operation end, operation type, operation object, operation data, and other information.
The action table module: the method comprises the steps of abstracting different business behaviors into general actions, and adding an action table, wherein the action table comprises a plurality of action types and implementation classes corresponding to the action types;
the task table module: the data used for adding the task list and triggering the task accords with the columns of screening conditions, executing actions, starting and stopping, serial numbers and the like, and when the message is consumed, a plurality of pieces of data in the corresponding action list are found in the task list and are sequentially executed according to the sequence;
the task table module is specifically used for: adding a task list, including task names, execution objects and trigger occasions, wherein the execution data need to meet the screening conditions, execution actions, start and stop, serial numbers and other columns, and finding out a plurality of pieces of data in the corresponding action list in the task list when the data operation message is consumed, and sequentially executing the data according to the sequence.
Message queue consumption service module: and the message queue consumption service is used for adding a message, triggering a task list according to the content of the message, acquiring a corresponding task list, sequentially judging whether the current service data accords with screening conditions configured on the task, and acquiring a corresponding implementation class from the action list according to the action type to execute the action if the current service data accords with the screening conditions.
The embodiment of the present invention is a system embodiment corresponding to the above method embodiment, and specific operations of each module may be understood by referring to the description of the method embodiment, which is not repeated herein.
Device embodiment 1
An embodiment of the present invention provides a decoupling device based on configuration of an instant trigger task, as shown in fig. 4, including: memory 40, processor 42, and a computer program stored on memory 40 and executable on processor 42, which when executed by the processor, performs the steps of the method embodiments described above.
Device example two
The embodiment of the present invention provides a computer readable storage medium, on which a program for implementing information transmission is stored, which when executed by the processor 42 implements the steps in the above-described method embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; and these modifications or substitutions may be made to the technical solutions of the embodiments of the present invention without departing from the spirit of the corresponding technical solutions.