Methods, apparatus, electronic equipment and media for processing business
By receiving cron expressions and using the Quartz framework to create and manage timing tasks, the problem of too concentrated timing tasks in the business system is solved, and efficient system processing and management is achieved.
Patent Information
- Application Number
- CN202210050850.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-01-17
AI Technical Summary
In the business system, multiple timing tasks are processed too centrally, resulting in increased system operation pressure and lack of an orderly processing mechanism.
Receive cron expressions sent by users through the Http interface and/or the message queue interface, create timing tasks using the Quartz framework, and record them in the task database table. When the task adjustment parameters are received, the corresponding timing task status is adjusted.
It realizes unified allocation and management of timing tasks, avoids the problem of over-concentrated task processing, and improves the system's processing efficiency and maintainability.
Smart Images

Figure CN114546674B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to data processing technology, and in particular to a method, device, electronic device and medium for processing business. Background Art
[0002] As the scale of software business continues to upgrade, the system architecture of software is also evolving. Microservice architecture has been used more and more, and the ever-increasing software system is split into single independent but mutually coordinated microservices.
[0003] Among them, the existence of microservice architecture enables each split scheduled task module to be developed independently, select the required functional components, and independently deploy and maintain them. At the same time, it can also handle the server for different scheduled tasks. However, when there are too many scheduled tasks to be found in the system, if multiple tasks cannot be uniformly allocated, it will lead to the problem of too centralized task processing in the system, which will lead to increased operating pressure. Summary of the invention
[0004] The embodiments of the present application provide a method, device, electronic device and medium for processing business, which are used to solve the problem of over-centralized processing caused by failure to orderly process various scheduled tasks in the business system in the related art.
[0005] According to one aspect of an embodiment of the present application, a method for processing a service is provided, including:
[0006] Utilize the Http interface and / or the message queue interface to receive the cron expression sent by the user for creating a scheduled service;
[0007] According to the cron expression and the Quartz framework, create at least one corresponding scheduled task, and record the at least one scheduled task in a preset task database table;
[0008] After receiving the task adjustment parameter for adjusting the target scheduled task, the corresponding target scheduled task in the task database table is adjusted according to the task adjustment parameter.
[0009] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0010] Receive a first cron expression using an Http interface, where the first cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0011] When it is determined based on the first cron expression that the creation of the first scheduled service is completed, the ID name of the first scheduled service, the first cron expression, and the first scheduled task information are recorded in the task database table.
[0012] Optionally, in another embodiment of the method of the present application, the step of using a message queue interface to receive a cron expression for creating a scheduled service sent by a user includes:
[0013] Receive a second cron expression using the Http interface, where the second cron expression includes the url of the http interface and a request message body implemented by the task;
[0014] When it is determined based on the second cron expression that the second scheduled service is created, the ID name of the second scheduled service, the second cron expression, and the second scheduled task information are recorded in the task database table.
[0015] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0016] Receiving a third cron expression by using an mq message of a pre-agreed first routing key, wherein the third cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0017] When it is determined based on the third cron expression that the creation of the third scheduled service is completed, the ID name of the third scheduled service, the third cron expression and the third scheduled task information are recorded in the task database table.
[0018] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0019] Receive a fourth cron expression using an mq message with a pre-agreed second routing key, wherein the fourth cron expression includes a url of the mq message and a request message body of the task implementation;
[0020] When it is determined based on the fourth cron expression that the fourth scheduled service is created, the ID name of the fourth scheduled service, the fourth cron expression and the fourth scheduled task information are recorded in the task database table.
[0021] Optionally, in another embodiment of the method of the present application, after receiving a task adjustment parameter for adjusting the target scheduled task, adjusting the corresponding target scheduled task in the task database table according to the task adjustment parameter includes:
[0022] After receiving the task adjustment parameter, determining the target scheduled task corresponding to the service ID name according to the service ID name carried in the task adjustment parameter;
[0023] The target business parameters corresponding to the target scheduled task are searched in the task database table, and the task state of the target scheduled task is adjusted by adjusting the target business parameters, wherein the task state includes one of pause, resume and delete.
[0024] According to another aspect of the embodiment of the present application, a device for processing a service is provided, characterized in that it includes:
[0025] The receiving module is configured to use the Http interface and / or the message queue interface to receive the cron expression sent by the user for creating a scheduled service;
[0026] A creation module is configured to create at least one corresponding scheduled task according to the cron expression and the Quartz framework, and record the at least one scheduled task into a preset task database table;
[0027] The adjustment module is configured to adjust the corresponding target scheduled task in the task database table according to the task adjustment parameter after receiving the task adjustment parameter for adjusting the target scheduled task.
[0028] According to another aspect of the embodiments of the present application, an electronic device is provided, including:
[0029] A memory for storing executable instructions; and
[0030] A display is used to execute the executable instructions together with the memory to complete the operation of any of the above-mentioned methods for processing business.
[0031] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided for storing computer-readable instructions, which, when executed, perform the operations of any of the above-mentioned methods for processing business.
[0032] In the present application, the Http interface and / or the message queue interface can be used to receive the cron expression issued by the user for creating a scheduled business; according to the cron expression and the Quartz framework, at least one corresponding scheduled task is created, and at least one scheduled task is recorded in the preset task database table; after receiving the task adjustment parameters for adjusting the target scheduled task, the corresponding target scheduled task in the task database table is adjusted according to the task adjustment parameters. By applying the technical solution of the present application, a set of scheduled task service methods based on the quartz framework is provided, so that the quartz framework can be used to provide a complete scheduled task service, and the scheduled task service is completely decoupled from the business system. At the same time, a database is added to save the scheduled task information, so that a unified entry for viewing and managing scheduled tasks can be provided. This avoids the problem of over-centralized processing caused by the failure to orderly process each scheduled task in the business system in the related art.
[0033] The technical solution of the present application is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present application and, together with the description, serve to explain the principles of the present application.
[0035] The present application can be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0036] Figure 1 A schematic diagram of a method for processing business proposed in this application;
[0037] Figure 2-4 A flowchart of a business processing method for an application under a microservice architecture proposed in this application;
[0038] Figure 5 A schematic diagram of the structure of an electronic device for processing business proposed in this application;
[0039] Figure 6 This is a schematic diagram of the structure of an electronic device for processing business proposed in this application. DETAILED DESCRIPTION
[0040] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present application.
[0041] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0042] The following description of at least one exemplary embodiment is merely illustrative in nature and is not intended to limit the present application, its application, or uses.
[0043] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0044] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0045] In addition, the technical solutions between the various embodiments of the present application can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0046] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0047] Combine the following Figure 1-Figure 4 To describe the method for processing business according to the exemplary embodiment of the present application. It should be noted that the following application scenarios are only shown to facilitate understanding of the spirit and principle of the present application, and the embodiments of the present application are not limited in this respect. On the contrary, the embodiments of the present application can be applied to any applicable scenario.
[0048] The present application also proposes a method, device, electronic device and medium for processing business.
[0049] Figure 1 The flowchart of a method for processing business according to an embodiment of the present application is schematically shown. Figure 1 As shown, the method includes:
[0050] S101, using the Http interface and / or the message queue interface to receive a cron expression sent by a user for creating a scheduled service.
[0051] S102: Create at least one corresponding scheduled task according to the cron expression and the Quartz framework, and record the at least one scheduled task into a preset task database table.
[0052] S103, after receiving the task adjustment parameters for adjusting the target scheduled task, adjusting the corresponding target scheduled task in the task database table according to the task adjustment parameters.
[0053] In the related technologies, as the scale of software business continues to upgrade, the system architecture of software is also evolving. Microservice architecture has been used more and more, and the software system with increasing scale is split into single independent but mutually coordinated microservices. The existence of microservice architecture enables each split business module to be developed independently, select the required functional components, and independently deploy and maintain them. At the same time, it can also scale the server for different businesses. However, if you blindly pursue microservice architecture, first, the requirements for distributed systems are high, and second, some products and developers have problems with the splitting of microservices due to insufficient technical level and business analysis capabilities. As a result, the overlap of business and the coupling of development lead to too much interaction between teams, and they cannot focus on the business of the development task itself, or repeatedly develop a large amount of redundant code, or put too much pressure on some services themselves, or cause high communication pressure between services, which adds unnecessary consumption and maintenance costs to the entire team and software system.
[0054] Scheduled tasks are also a very important part of current software functions. Existing Java methods for implementing scheduled tasks mainly include timer class, thread delay, scheduler thread pool, delay queue, and quartz open source framework. Among them, the quartz framework has the most comprehensive functions. It can use cron expressions to achieve the requirements of various scheduled tasks. It also provides functions such as task query, pause and resume of scheduled tasks, and reply after downtime. However, as a complete scheduled task solution, quartz is inevitably overly heavy in code.
[0055] In the current microservice architecture system development, scheduled tasks, as a function required by almost every service, are a high-incidence area for such redundant costs.
[0056] Furthermore, a process of a method for processing business proposed in this application may include the following steps:
[0057] According to the requirements of the quartz framework, realize the basic timing task function;
[0058] First, this application can implement four sets of scheduled task creation methods. Two of them are based on http interface, which are general or customized task implementations implemented by scheduled task service using reflection call; and scheduled task service is only responsible for scheduled call of business service task implementation http interface. The other two sets are based on mq monitoring, which are general or customized task implementations implemented by scheduled task service using reflection call; and scheduled task service is only responsible for scheduled message notification, using mq to notify the message monitoring handler of business service.
[0059] In one way, after creating a scheduled task, the application can also add a database table to record the status of the scheduled task in addition to the database that comes with the Quartz framework when operating the scheduled scheduler. In addition, the scheduled task service can develop several general or customized task implementation classes and methods according to the overall system requirements. After reaching the scheduled time point, it uses reflection to call the specified method to complete the implementation of the scheduled task.
[0060] Furthermore, when creating a scheduled task, the business module of the present application can select the http method or the mq method to send the creation request to the scheduled task module. The task implementation processing, according to the needs and project progress, selects the final implementation to be implemented by the scheduled task module, or the business module itself. Corresponding to the four scheduled task creation methods mentioned above, respectively, using the Http interface and / or the message queue interface to receive the cron expression sent by the user for creating a scheduled business.
[0061] In one method, when a business service needs to use a scheduled task, the application can send the relevant parameters to the queue monitored by the scheduled task through the message queue mq according to the routing key specified by the scheduled task service. The scheduled task service needs to listen to the direct exchange bound to the specified routing key to obtain the creation information of the scheduled task and save it. Through the quartz framework, when the scheduled task trigger point is reached, the relevant content is pushed to the mq as required.
[0062] In one approach, the business module needs to implement a set of MQ-based RPC communication mechanisms. When building the service, different task implementation handler classes are created into a map using annotations. According to different routing keys, switch types, and message contents, the specific implementation handlers and methods of the messages pushed by the scheduled tasks are determined, and specific tasks are implemented in the handler class. This RPC communication mechanism can be used not only for notifications of scheduled tasks, but also for regular inter-service communication.
[0063] In the present application, the Http interface and / or the message queue interface can be used to receive the cron expression for creating a scheduled business issued by the user; according to the cron expression and the Quartz framework, at least one corresponding scheduled task is created, and at least one scheduled task is recorded in the preset task database table; after receiving the task adjustment parameter for adjusting the target scheduled task, the corresponding target scheduled task in the task database table is adjusted according to the task adjustment parameter. By applying the technical solution of the present application, a set of scheduled task service methods based on the quartz framework is provided, so that the quartz framework can be used to provide a complete scheduled task service, and the scheduled task service is completely decoupled from the business system. At the same time, a database is added to save the scheduled task information, so that a unified entry for viewing and managing scheduled tasks can be provided. Thus, the problem of excessive concentration of processing caused by the failure to orderly process each scheduled task in the business system existing in the related art is avoided. After receiving the message, the business information such as the notification message can be directly pushed to the enterprise WeChat platform. So that the enterprise WeChat platform completes the message sending to each user to be notified. Thereby reducing the processing burden of the platform itself. Thus, the problem of large processing volume caused by sending relevant messages to business personnel immediately in the related art is avoided. It performs fault probability detection and optimizes the model based on historical collection data and maintenance data, thereby determining in real time whether there are faulty equipment nodes in the business plant line. This avoids the time-consuming problem in related technologies of manually determining whether there are faulty equipment nodes in the data collected by the equipment collection nodes.
[0064] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0065] Receive a first cron expression using an Http interface, where the first cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0066] When it is determined based on the first cron expression that the creation of the first scheduled service is completed, the ID name of the first scheduled service, the first cron expression, and the first scheduled task information are recorded in the task database table.
[0067] Optionally, in another embodiment of the method of the present application, the step of using a message queue interface to receive a cron expression for creating a scheduled service sent by a user includes:
[0068] Receive a second cron expression using the Http interface, where the second cron expression includes the url of the http interface and a request message body implemented by the task;
[0069] When it is determined based on the second cron expression that the second scheduled service is created, the ID name of the second scheduled service, the second cron expression, and the second scheduled task information are recorded in the task database table.
[0070] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0071] Receiving a third cron expression by using an mq message of a pre-agreed first routing key, wherein the third cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0072] When it is determined based on the third cron expression that the creation of the third scheduled service is completed, the ID name of the third scheduled service, the third cron expression and the third scheduled task information are recorded in the task database table.
[0073] Optionally, in another embodiment of the method of the present application, the step of using an Http interface to receive a cron expression sent by a user for creating a scheduled service includes:
[0074] Receive a fourth cron expression using an mq message with a pre-agreed second routing key, wherein the fourth cron expression includes a url of the mq message and a request message body of the task implementation;
[0075] When it is determined based on the fourth cron expression that the fourth scheduled service is created, the ID name of the fourth scheduled service, the fourth cron expression and the fourth scheduled task information are recorded in the task database table.
[0076] Optionally, in another embodiment of the method of the present application, after receiving a task adjustment parameter for adjusting the target scheduled task, adjusting the corresponding target scheduled task in the task database table according to the task adjustment parameter includes:
[0077] After receiving the task adjustment parameter, determining the target scheduled task corresponding to the service ID name according to the service ID name carried in the task adjustment parameter;
[0078] The target business parameters corresponding to the target scheduled task are searched in the task database table, and the task state of the target scheduled task is adjusted by adjusting the target business parameters, wherein the task state includes one of pause, resume and delete.
[0079] In one way, Figure 2As shown, it is a flowchart proposed by the present application for using the Http interface and / or the message queue interface to receive the cron expression issued by the user for creating a scheduled service, and creating at least one corresponding scheduled task according to the cron expression and the Quartz framework, and recording at least one scheduled task in a preset task database table, which includes:
[0080] First way:
[0081] The first cron expression is received by using the Http interface, and the first cron expression includes the name of the scheduled service and the corresponding service type parameter. When it is determined based on the first cron expression that the first scheduled service is created, the ID name of the first scheduled service, the first cron expression and the first scheduled task information are recorded in the task database table.
[0082] Furthermore, the main parameters received by the http interface proposed in this application are the scheduled cron expression, the task implementation class of the scheduled task service module, the method name and method parameters, etc.; its method is implemented by utilizing the java reflection mechanism to call the task implementation class in the scheduled task service according to the passed class name, method name, and parameters; its return value is the Id of the scheduled task.
[0083] Second way:
[0084] Receive a second cron expression using the Http interface, where the second cron expression includes the url of the http interface and a request message body implemented by the task;
[0085] When it is determined based on the second cron expression that the second scheduled service is created, the ID name of the second scheduled service, the second cron expression, and the second scheduled task information are recorded in the task database table.
[0086] Furthermore, the main parameters of the http interface input proposed in this application are the scheduled cron expression, the url of the http interface of the corresponding task implementation method of the business module and the request message body of the task implementation; its implementation is to directly call the http interface; its return value is the ID of the scheduled task;
[0087] The third way:
[0088] Receiving a third cron expression by using an mq message of a pre-agreed first routing key, wherein the third cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0089] When it is determined based on the third cron expression that the creation of the third scheduled service is completed, the ID name of the third scheduled service, the third cron expression and the third scheduled task information are recorded in the task database table.
[0090] Furthermore, the present application proposes to monitor the MQ message of a direct exchange (hereinafter the same) bound to an agreed routing key (hereinafter the same), the main parameters of the message are the scheduled cron expression, the task implementation class of the scheduled task service module, the method name and method parameters, etc.; its implementation is to use java reflection to call the task implementation class in the scheduled task service according to the class name, method name, and parameters; its return value is the ID of the scheduled task.
[0091] The fourth method:
[0092] Receive a fourth cron expression using an mq message with a pre-agreed second routing key, wherein the fourth cron expression includes a url of the mq message and a request message body of the task implementation;
[0093] When it is determined based on the fourth cron expression that the fourth scheduled service is created, the ID name of the fourth scheduled service, the fourth cron expression and the fourth scheduled task information are recorded in the task database table.
[0094] The application proposes to monitor the MQ message of a direct switch bound to an agreed routing key. The incoming message parameters are the forwarding routing key, routing mode (unicast or broadcast), and the context used for task implementation. The implementation is to push the message with the specified routing key or routing mode. The return value is the ID of the scheduled task.
[0095] It should be noted that the above four methods all have cron expression parameters, and through the Quartz framework, the corresponding scheduled task registration and subsequent control can be completed.
[0096] Further, such as Figure 3 As shown, this application also needs to implement two sets of adjustment methods for scheduled tasks, http and mq. When the business module needs to adjust the scheduled tasks that have been created, the ID of the corresponding scheduled task is sent via http or mq, that is, the implementation function of the quartz framework can be used to pause, resume, modify cron timing, delete, and other operations on the existing scheduled tasks.
[0097] In addition, for the creation and implementation of scheduled tasks, the scheduled task service needs to implement several sets of common scheduled task methods according to business needs for direct calls by other services; at the same time, according to the requirements of other business modules, a customized scheduled task implementation class can be developed in the scheduled task service. However, this method is not recommended and will lead to business coupling.
[0098] In one way, the application can also add MQ monitoring. The principle of reflection can be used to enable the scheduled tasks to be customized and executed in a diversified manner according to different business requirements, but the specific implementation logic is still in the scheduled task service; and the created scheduled tasks can decouple the task implementation from the timing, so that the scheduled task service only needs to maintain the timing function, and the business developers only need to make the corresponding interface or monitoring handle, without paying attention to the implementation details of the timing, and focus on solving the business itself.
[0099] Furthermore, Figure 4 As shown, the business service module first needs to configure the application's support for RabbitMQ. RabbitMQ uses the AMQP protocol and supports multiple types of exchanges to handle message sending and receiving. A new custom annotation is added to the Java program. This annotation needs to add a parameter, which is similar to the URL and is mainly used to agree on the location of a specific processing class.
[0100] In the Java program, a new handle is defined, which can be an abstract class or an interface. One or more methods need to be defined. The subsequent implementation class of this class is the corresponding task implementation class, and the method is the task implementation method. Annotations need to be added to its implementation class. Different methods correspond to different message source processing.
[0101] Among them, a unified mq message listening class is implemented in the java program. Its init method scans all annotated parameters as keys, and the annotated classes are stored in a hashmap as values. The init method needs to be called when the project starts. The message processing class needs to implement one or more listening processes.
[0102] Finally, when receiving an mq message, different listening processing methods can be entered according to different routing keys. At this time, according to the specified field class url in the message, the specific processing class is matched from the map. Since the processing classes are all subclasses of the defined abstract class or interface, unified processing can be performed by directly calling the task implementation method defined in the corresponding subclass, that is, different class url fields correspond to different handle implementation methods of the same subclass.
[0103] Different monitoring processing methods correspond to multiple methods of a single subclass, that is, it can process messages from different message sources, so that a single handle implementation class can focus on the different processing processes of a single type of problem for different message initiators, as well as the overall forwarding positioning.
[0104] Finally, since there is a unified message processing class in the above process, the reply to RPC messages, permission-related verification, exception capture and processing and other operations can be completed in this class, or the message content can be processed according to business requirements, as well as diversion and current limiting.
[0105] In addition, by applying the technical solution of the present application, a set of scheduled task service methods based on the quartz framework is provided, thereby realizing that the quartz framework can provide a complete scheduled task service, and the scheduled task service is completely decoupled from the business system. At the same time, a database is added to save the scheduled task information, so that a unified entry for viewing and managing scheduled tasks can be provided. This avoids the problem of over-centralized processing caused by the failure to orderly process each scheduled task in the business system in the related art.
[0106] Optionally, the above solution of this application actually proposes a general service communication processing method based on MQ. By utilizing the characteristics of MQ, asynchronous non-blocking RPC processing can be realized relatively simply. The ACK mechanism of MQ can ensure the high accessibility of messages in various scenarios as much as possible, and the master-slave mirroring of MQ can ensure its own high availability. The RPC communication mechanism based on this implementation can almost meet the communication within the service in most scenarios and microservice architectures under high traffic. It can be repeatedly developed as a general communication framework within the system, and it is also convenient for other customization and function expansion of each business itself.
[0107] Optionally, in another embodiment of the present application, Figure 5 As shown, the present application also provides a device for processing business. It includes:
[0108] The receiving module 201 is configured to use an Http interface and / or a message queue interface to receive a cron expression for creating a scheduled service sent by a user;
[0109] A creation module 202 is configured to create at least one corresponding scheduled task according to the cron expression and the Quartz framework, and record the at least one scheduled task into a preset task database table;
[0110] The adjustment module 203 is configured to adjust the corresponding target scheduled task in the task database table according to the task adjustment parameter after receiving the task adjustment parameter for adjusting the target scheduled task.
[0111] In the present application, the Http interface and / or the message queue interface can be used to receive the cron expression issued by the user for creating a scheduled business; according to the cron expression and the Quartz framework, at least one corresponding scheduled task is created, and at least one scheduled task is recorded in the preset task database table; after receiving the task adjustment parameters for adjusting the target scheduled task, the corresponding target scheduled task in the task database table is adjusted according to the task adjustment parameters. By applying the technical solution of the present application, a set of scheduled task service methods based on the quartz framework is provided, so that the quartz framework can be used to provide a complete scheduled task service, and the scheduled task service is completely decoupled from the business system. At the same time, a database is added to save the scheduled task information, so that a unified entry for viewing and managing scheduled tasks can be provided. This avoids the problem of over-centralized processing caused by the failure to orderly process each scheduled task in the business system in the related art.
[0112] In another embodiment of the present application, the receiving module 201 is configured to perform the following steps:
[0113] Receive a first cron expression using an Http interface, where the first cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0114] When it is determined based on the first cron expression that the creation of the first scheduled service is completed, the ID name of the first scheduled service, the first cron expression, and the first scheduled task information are recorded in the task database table.
[0115] In another embodiment of the present application, the receiving module 201 is configured to perform the following steps:
[0116] Receive a second cron expression using the Http interface, where the second cron expression includes the url of the http interface and a request message body implemented by the task;
[0117] When it is determined based on the second cron expression that the second scheduled service is created, the ID name of the second scheduled service, the second cron expression, and the second scheduled task information are recorded in the task database table.
[0118] In another embodiment of the present application, the receiving module 201 is configured to perform the following steps:
[0119] Receiving a third cron expression by using an mq message of a pre-agreed first routing key, wherein the third cron expression includes a name of a scheduled service and a corresponding service type parameter;
[0120] When it is determined based on the third cron expression that the creation of the third scheduled service is completed, the ID name of the third scheduled service, the third cron expression and the third scheduled task information are recorded in the task database table.
[0121] In another embodiment of the present application, the receiving module 201 is configured to perform the following steps:
[0122] Receive a fourth cron expression using an mq message with a pre-agreed second routing key, wherein the fourth cron expression includes a url of the mq message and a request message body of the task implementation;
[0123] When it is determined based on the fourth cron expression that the fourth scheduled service is created, the ID name of the fourth scheduled service, the fourth cron expression and the fourth scheduled task information are recorded in the task database table.
[0124] In another embodiment of the present application, the receiving module 201 is configured to perform the following steps:
[0125] After receiving the task adjustment parameter, determining the target scheduled task corresponding to the service ID name according to the service ID name carried in the task adjustment parameter;
[0126] The target business parameters corresponding to the target scheduled task are searched in the task database table, and the task state of the target scheduled task is adjusted by adjusting the target business parameters, wherein the task state includes one of pause, resume and delete.
[0127] Figure 6 3 is a logical structure block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0128] In an exemplary embodiment, a non-temporary computer-readable storage medium including instructions is also provided, such as a memory including instructions, the above instructions can be executed by an electronic device processor to complete the above method of processing business, the method comprising: using an Http interface, and / or a message queue interface to receive a cron expression issued by a user for creating a scheduled business; according to the cron expression and the Quartz framework, create at least one corresponding scheduled task, and record the at least one scheduled task in a preset task database table; after receiving a task adjustment parameter for adjusting a target scheduled task, adjust the corresponding target scheduled task in the task database table according to the task adjustment parameter. Optionally, the above instructions can also be executed by a processor of an electronic device to complete other steps involved in the above exemplary embodiment. For example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0129] In an exemplary embodiment, an application / computer program product is also provided, including one or more instructions, which can be executed by a processor of an electronic device to complete the above-mentioned method of processing business, the method comprising: using an Http interface and / or a message queue interface to receive a cron expression issued by a user for creating a scheduled business; according to the cron expression and the Quartz framework, create at least one corresponding scheduled task, and record the at least one scheduled task in a preset task database table; after receiving a task adjustment parameter for adjusting a target scheduled task, adjust the corresponding target scheduled task in the task database table according to the task adjustment parameter. Optionally, the above-mentioned instructions can also be executed by a processor of an electronic device to complete other steps involved in the above-mentioned exemplary embodiment.
[0130] Those skilled in the art will understand that Figure 6 It is only an example of the electronic device 300 and does not constitute a limitation of the electronic device 300. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 300 may also include input and output devices, network access devices, buses, etc.
[0131] The processor 302 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor 302 may also be any conventional processor, etc. The processor 302 is the control center of the electronic device 300, and uses various interfaces and lines to connect various parts of the entire electronic device 300.
[0132] The memory 301 can be used to store computer-readable instructions. The processor 302 implements various functions of the electronic device 300 by running or executing the computer-readable instructions or modules stored in the memory 301 and calling the data stored in the memory 301. The memory 301 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device 300, etc. In addition, the memory 301 can include a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM) or other non-volatile / volatile storage devices.
[0133] If the module integrated in the electronic device 300 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware to complete it through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when the computer-readable instructions are executed by the processor, the steps of the above-mentioned various method embodiments can be implemented.
[0134] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0135] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for processing business, characterized in that: Applicable to the Quartz framework, including: Use the Http interface and message queue interface to receive the cron expressions sent by users for creating scheduled services; According to the cron expression and the Quartz framework, create at least one corresponding scheduled task, and record the at least one scheduled task in a preset task database table; After receiving the task adjustment parameter for adjusting the target scheduled task, adjusting the corresponding target scheduled task in the task database table according to the task adjustment parameter; Wherein, when the cron expression is received by the message queue interface, Define a new handle and one or more methods in the Java program. The subsequent implementation class is the specific message processing class. The method is the task implementation method. Annotations need to be added to its implementation class. Different methods correspond to different message source processing. Implement a unified mq message monitoring class in the java program. Its init method scans all annotated parameters as keys, and stores the annotated classes as values in a hashmap. The init method needs to be called when the project starts, and the message processing class needs to implement one or more monitoring processes. When an MQ message is received, different listening processing methods are entered according to different routing keys. At this time, according to the specified field class url in the message, the specific processing class is matched from the map. Since the processing classes are all subclasses of the defined abstract class or interface, they can be processed uniformly by directly calling the task implementation method defined by the corresponding subclass. Different class url fields correspond to different handle implementation methods of the same subclass; and different listening processing methods correspond to multiple methods of a single subclass, which can process messages from different message sources.
2. The method according to claim 1, characterized in that The method of using the Http interface to receive a cron expression sent by a user for creating a scheduled service includes: Receive a first cron expression using an Http interface, where the first cron expression includes a name of a scheduled service and a corresponding service type parameter; When it is determined based on the first cron expression that the creation of the first scheduled service is completed, the ID name of the first scheduled service, the first cron expression, and the first scheduled task information are recorded in the task database table.
3. The method according to claim 1, characterized in that The method of using the http interface to receive a cron expression sent by a user for creating a scheduled service includes: Utilize the Http interface to receive a second cron expression, wherein the second cron expression includes the url of the http interface and the request message body implemented by the task; When it is determined based on the second cron expression that the second scheduled service is created, the ID name of the second scheduled service, the second cron expression, and the second scheduled task information are recorded in the task database table.
4. The method according to claim 1, characterized in that The method of using the message queue interface to receive a cron expression sent by a user for creating a scheduled service includes: Receiving a third cron expression by using an mq message of a pre-agreed first routing key, wherein the third cron expression includes a name of a scheduled service and a corresponding service type parameter; When it is determined based on the third cron expression that the creation of the third scheduled service is completed, the ID name of the third scheduled service, the third cron expression and the third scheduled task information are recorded in the task database table.
5. The method according to claim 1, characterized in that The method of using the message queue interface to receive a cron expression sent by a user for creating a scheduled service includes: Receive a fourth cron expression using an mq message with a pre-agreed second routing key, wherein the fourth cron expression includes a url of the mq message and a request message body of the task implementation; When it is determined based on the fourth cron expression that the fourth scheduled service is created, the ID name of the fourth scheduled service, the fourth cron expression and the fourth scheduled task information are recorded in the task database table.
6. The method according to claim 1, characterized in that After receiving the task adjustment parameter for adjusting the target scheduled task, adjusting the corresponding target scheduled task in the task database table according to the task adjustment parameter includes: After receiving the task adjustment parameter, determining the target scheduled task corresponding to the service ID name according to the service ID name carried in the task adjustment parameter; The target business parameters corresponding to the target scheduled task are searched in the task database table, and the task state of the target scheduled task is adjusted by adjusting the target business parameters, wherein the task state includes one of pause, resume and delete.
7. A device for processing services, used in any of the methods of claims 1-6, characterized in that: Applicable to the Quartz framework, including: The receiving module is configured to use the Http interface and / or the message queue interface to receive the cron expression sent by the user for creating a scheduled service; A creation module is configured to create at least one corresponding scheduled task according to the cron expression and the Quartz framework, and record the at least one scheduled task into a preset task database table; The adjustment module is configured to adjust the corresponding target scheduled task in the task database table according to the task adjustment parameter after receiving the task adjustment parameter for adjusting the target scheduled task.
8. An electronic device, characterized in that: include: A memory for storing executable instructions; as well as, A processor is used to execute the executable instructions with the memory to complete the operation of the method for processing business described in any one of claims 1-6.
9. A computer-readable storage medium for storing computer-readable instructions, characterized in that: When the instructions are executed, the operations of the method for processing services described in any one of claims 1 to 6 are performed.
Citation Information
Patent Citations
Timing task execution method, distributed server cluster and electronic device
CN109582466A
Task scheduling method and device
CN110058930A