मैं वसंत-बूट (संस्करण 1.3.6) और क्वार्ट्ज और मैं सोच रहा हूँ क्या Spring-scheduler के साथ एक कार्य कर रही है के बीच का अंतर है नया हूँ:वसंत के साथ क्वार्ट्ज नौकरी और शेड्यूलिंग कार्य के बीच अंतर?
@Scheduled(fixedRate = 40000)
public void reportCurrentTime() {
System.out.println("Hello World");
}
और Quartz way:
0. Create sheduler.
1. Job which implements Job interface.
2. Create JobDetail which is instance of the job using the builder org.quartz.JobBuilder.newJob(MyJob.class)
3. Create a Triger
4. Finally set the job and the trigger to the scheduler
public class HelloJob implements Job {
public HelloJob() {
}
public void execute(JobExecutionContext context)
throws JobExecutionException
{
System.err.println("Hello!");
}
}
और sheduler:
कोड मेंSchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
Scheduler sched = schedFact.getScheduler();
sched.start();
// define the job and tie it to our HelloJob class
JobDetail job = newJob(HelloJob.class)
.withIdentity("myJob", "group1")
.build();
// Trigger the job to run now, and then every 40 seconds
Trigger trigger = newTrigger()
.withIdentity("myTrigger", "group1")
.startNow()
.withSchedule(simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
// Tell quartz to schedule the job using our trigger
sched.scheduleJob(job, trigger);
क्या क्वार्ट्ज जॉब्स, ट्रिगर और शेड्यूलर या स्प्रिंग शेड्यूलर को परिभाषित करने के लिए अधिक सुविधाजनक तरीका प्रदान करता है जो कुछ और बेहतर है?