quartz-scheduler

Quartz scheduler in cluster environment

孤者浪人 提交于 2019-11-28 03:58:37
I am using SchedulerFactory schedulerFactory = new StdSchedulerFactory(); scheduler = schedulerFactory.getScheduler(); scheduler.start(); Trigger asapTrigger = getAsapTrigger(); JobDetail asapJob = getAsapJobDetails(); scheduler.scheduleJob(asapJob, asapTrigger); This is working but when I go for cluster environment, 2 threads are running for the same job. I am using annotations not properties file. I want to run only one thread. Can someone help on this. How to configure? my code almost look like : http://k2java.blogspot.com/2011/04/quartz.html You have to configure Quartz to run in a

Retrieve servletContext reference in quartz scheduler

为君一笑 提交于 2019-11-27 23:18:54
I am using Quartz Scheduler with my spring 3.0 based application. I am successfully able to create new schedulers and they are working fine. I have seen thus reference. But.. I am not able to retrieve servletContext in my quartz job file. can anyone help me for How to retrieve servletContext reference in executeInternal() method ?? Gunjan Shah, thx. Boro I had a similar need. I sorted it out in a similar fashion to the solution presented here. In my servlet context listener I am setting the servlet context using the job data map object which then is set for a job: @Override public void

Quartz - schedule jobs every two Weeks on several Day of week and time

邮差的信 提交于 2019-11-27 23:15:43
I need to create Job that will : starts one 12/20/2012 endDate = 12/31/2017 will occur every 2 weeks on Sunday and monday fires at 5 pm. is this cron expression valid? Date start = 12/20/2012; Date endDate = 12/31/2017; SimpleTrigger trigger = newTrigger() .withIdentity("trigger3", "group1") .startAt(startDate) .withSchedule(cronSchedule("* * 17 0 0/2 *,SUN,MON").build()) .endAt(endDate) .build; Please advise. I suggest, that you make a unit test based on your cron expression. With kudos to Van de Voorde Toni , you can base it on this code, and use it to verify that the "nextValidTimeAfter"

Select node in Quartz cluster to execute a job

寵の児 提交于 2019-11-27 22:58:59
I have some questions about Quartz clustering, specifically about how triggers fire / jobs execute within the cluster. Does quartz give any preference to nodes when executing jobs? Such as always or never the node that executed the same job the last time, or is it simply whichever node that gets to the job first? Is it possible to specify the node which should execute the job? The answer to this will be something of a "it depends". For quartz 1.x, the answer is that the execution of the job is always (only) on a more-or-less random node. Where "randomness" is really based on whichever node

Quartz job triggering from Config.groovy

本小妞迷上赌 提交于 2019-11-27 22:47:02
问题 I have the following Quartz job running in my application: class ScraperJob { def scraperService static triggers = { cron name: 'scraperTrigger', cronExpression: "0 0 * * * ?" // run every minute } def execute(){ try { scraperService.storing() log.info "${new Date()} - Scraping went smoothly." } catch(IOException) { // Connexion problem log.error "${new Date()} - Method: parsing >> Connexion down or interrupted while parsing !" } catch(SAXException) { // Any SAXParser exception log.error "$

Quartz job runs twice when deployed on tomcat 6/Ubuntu 10.04LTS

主宰稳场 提交于 2019-11-27 21:52:45
问题 I run a Spring Framework/SmartGWT based web-app, with now an added Quartz job. The job is supposed to run every day at 2am, and picks winners from a DB table. From my logs I see it runs twice, concurrently it seems, because as you can see, the logs overlap: Generating winners of yesterday... Generating winners of yesterday... winning id's: 15 done, mail queue is filled. winning id's: 18 done, mail queue is filled. My applicationContext.xml looks like this: <!-- initiates and calls the job -->

Quartz Java resuming a job excecutes it many times

二次信任 提交于 2019-11-27 17:32:28
For my application i create jobs and schedule them with CronTriggers. Each job has only one trigger and both the job name and the trigger names are the same. No jobs share a trigger. Now when i create a cron trigger like this "0/1 * * * * ?" which instructs the job to execute every second, it works just fine. The problem rises when i first pause the job by calling : scheduler.pauseJob(jobName, jobGroup); and then resuming the job after let's say 50 seconds with : scheduler.resumeJob(jobName, jobGroup); What i see is that for these 50 seconds the job did not execute as requested. But the moment

How to get and set a global object in Java servlet context

拜拜、爱过 提交于 2019-11-27 13:13:46
I wonder if anyone can advise: I have a scenario where a scheduled job being run by Quartz will update an arraylist of objects every hour. But I need this arraylist of objects to be visible to all sessions created by Tomcat. So what I'm thinking is that I write this object somewhere every hour from the Quartz job that runs so that each session can access it. Can anyone say how best this may be achieved? I was wondering about the object being written to servlet context from the Quartz job? The alternative is having each session populate the arraylist of objects from a database table. Thanks Mr

Simple example for Quartz 2.2 and Tomcat 7

自作多情 提交于 2019-11-27 10:34:20
I want to create a scheduler with Quartz 2.2 in java dynamic web application. I am new to this task. I tried all the tutorials around the web. I trying context listener method to initialize the scheduler. It doesn't seem like working. The hello world program only works in general java application. for web application its looks tricky. pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>test

Java Example: Dynamic Job Scheduling with Quartz

孤者浪人 提交于 2019-11-27 09:29:55
问题 I want to expose an user interface to define Quartz JOBs dynamically. Where user should have facility to define JOBs properties like JOB name, cron expression or time interval, specific java class for task etc. Is there any Open Source that facilitates this feature? Or, If I want to create my own module for dynamic Quartz Scheduler, what should be the way to do so? 回答1: Example code for Dynamic Quartz JOB Scheduling: Maven Dependencies <dependency> <groupId>org.quartz-scheduler</groupId>