I need to use Quartz to manage a variety of tasks,
Written program based on Quartz deployment after the operation, in the process of system operation, will increase a lot of new tasks,
These new task, how to register a running program?
Because Quartz is through the JobBuilder. NewJob (XXX. Class), write the code,
Customers will increase demand at any time, I will according to customer demand, write the corresponding Job program, these newly written Job application, how to register a running program?
I mean, in the program is run, the new increase a job,
CodePudding user response:
Call the Scheduler. ScheduleJob can ah
CodePudding user response:
Don't stop to update? Code then give yourself a back door, such as listening to a port, port to the program through the command, and dynamic loading your specify the location of the class, then register to the timing task,
CodePudding user response:
reference 1st floor windowsoahil response: call Scheduler. O scheduleJob can This just scheduling tasks, but the root of the problem is scheduling tasks you need to specify the JOB of the full name of the class, I was hoping to schedule according to the requirements of the JOB object CodePudding user response:
refer to the second floor define_us response: non-stop updated? Code then give yourself a back door, such as listening to a port, port to the program through the command, and dynamic loading your specify the location of the class, then register to the timing task, Is hoping to scheduling according to the requirements of the job object, specify the name of the class all tasks will advance programming well, can't cope with the demand, CodePudding user response:
Quartz can pass parameters, design good a job class in advance, according to the different parameters is routed to the concrete to invoke services, because it is as you say, don't need to restart, there must be rules, now that there are rules can consider from the aspects of the implementation But you did not say more I cannot know you don't need to restart can add new functionality is implemented CodePudding user response:
reference event response: son, 4/f Quote: refer to the second floor define_us response: Don't stop to update? Code then give yourself a back door, such as listening to a port, port to the program through the command, and dynamic loading your specify the location of the class, then register to the timing task, Is hoping to scheduling according to the requirements of the job object, specify the name of the class all tasks must be prior programming well, can't cope with the demand, Specific what I mean is that you need a new job put new jars in a directory, then the jar package path through the back door to the life and class to the JVM to let him go to the development of new dynamic load the jar package, and then by passing in the name of the class of the reflection classes to register into the job, CodePudding user response:
You don't this done? Will you please share your code? CodePudding user response:
Can design a job regularly scan alone if there is a new job, and then dynamically add new job CodePudding user response:
refer to 7th floor qq_41994891 response: this to make you come yet? Will you please share your code? What to share this, this is the realization of the dynamic addition of quartz, of course he is based on the database Or you write a, based on the zk, such as cluster environment so that more CodePudding user response:
This is not spring environment, if there is a spring to the factory directly, it is ok that to add Through SchedulerFactory changes, but also get the scheduler, and then modify the inside of the trigger, the listener, a jobdetail CodePudding user response:
1. SchedulerFactory sf=new StdSchedulerFactory (); 2. The Scheduler Scheduler=sf. GetScheduler (); 3. The JobDetail JobDetail=new JobDetail (" SchedulerJob ", "run_manage", SchedulerJob class); 4. The Trigger, the Trigger=CronTrigger (String name, String group, String cronExpression); 5. The scheduler. ScheduleJob (jobDetail, trigger); CodePudding user response:
Can be considered accomplished by means of reflection? Full name of the class directly through parameter specifies, call it what you want, directly reflect the realization of the corresponding class, and then get all the name of the class to add to the task CodePudding user response:
Regularly scan a package, there are new requirements under the upload class files to the package, and then add this class to the timing in the task (or you can also use a thread to do, a new class to open a new thread, with sleep timing effect). CodePudding user response:
You can add the job you want to call a lock, unlock accords with a condition CodePudding user response:
Recently, our program also met this requirement, because we use project is XXL - job, so it is rewrite the XXL - job API, and encapsulate interface for our calls on its own, perfectly solve the runtime dynamically add timing task requirements CodePudding user response:
The Scheduler sched=new StdSchedulerFactory (.) getScheduler (); JobDetail JobDetail=new JobDetail (" jobName ", "JOB_GROUP_NAME", the Job class);//task name, task group, task execution class CronTrigger trigger=new CronTrigger (" jobName ", "JOB_GROUP_NAME");//the trigger, the trigger group The trigger. SetCronExpression (" time ");//the trigger time setting Sched. ScheduleJob (jobDetail, trigger); //start if (! Sched. IsShutdown ()) { Sched. Start (); } CodePudding user response:
This function I do at this stage to dynamically generate compiled Java classes. The class, the class loader in memory, but it is quartz myself when I'm in the call to get the data inventory of reflex loaded full path name of the class itself is in the classpath, use after springboot into jar not line, pain about this point