Author Message
Tanaji_Bhale
Joined: Sep 26, 2016
Messages: 64
Offline
Hi,

I'm using Quartz scheduler 2.1.5 in snap-in (breeze sdk 3.3.1.0.0733100) to periodically fetch (i.e. every 3 min while testing) some data and store into my oracle db, but the problem i'm facing here is quartz stop triggering job after few successful execution without any error msg. lets say quartz thread count is 5 then it stops firing trigger after 5 successful execution of job, I'm really wondering what is wrong here as I confirmed that the same code work fine when I run it as standalone java app but it fails when I put this into snap-in . Hoping for a prompt and detailed response.

code to schedule TestJob using StdSchedulerFactory :

cronExpression = "0 0/3 * * * ?";

JobDetail job = JobBuilder.newJob(TestJob.class).withIdentity("TestJob", "DataParser").build();
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("TestJob", "DataParser")
.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);


Code for TestJob.java:


public class TestJob implements Job {

private static Logger logger = Logger.getLogger(TestJob.class);

private DataClient dataClient = null;
private DataProcesser parserService = new DataProcesserImpl();
private Date lastExecutionDate = null;

/**
* Default Constructor
*/
public TestJob() {
}

@Override
public void execute(JobExecutionContext jobContext) throws JobExecutionException {
Date endDate = new Date();
if (lastExecutionDate == null) {
lastExecutionDate = new Date(endDate.getTime() - 15 * 1000);
}
logger.info("Parser Job[Start Date: " + DateFormatter.formatDate(lastExecutionDate) + ", End Date: "
+ DateFormatter.formatDate(endDate) + " ]");
try {
dataClient = DataClient.getInstance();
PageDataExport pageData = dataClient.getData(lastExecutionDate, endDate);
if (pageData != null) {
parserService.processData(pageData);
}
lastExecutionDate = new Date();
} catch (Exception e) {
logger.error("Error in quartz job execution, " + e.getMessage());
}
}
}




Thanks & Regards,
Tanaji Bhale.
Tanaji_Bhale
Joined: Sep 26, 2016
Messages: 64
Offline
Quartz creates a fixed pool of worker threads (see org.quartz.threadPool.threadCount configuration option). Every time you run a job Quartz may decide to use a different thread - but it won't create new thread per every trigger.

Thanks & Regards,
Tanaji Bhale.
AnuragAggarwal
Joined: Jun 1, 2014
Messages: 154
Offline
quartz uses slf4j logging framework, following link has example

http://saltnlight5.blogspot.in/2013/08/how-to-create-web-app-with-quartz.html

this may help to find the issue
Go to:   
Mobile view