I'am using Quartz Scheduler in my Guice application, for some very simple job which should call some web service, and based on the response update rows in the database. The problem I have here is that the transactions are skipped or not committed when the service method is called from Quartz job, at least that's one of my doubts. so the rows are updated only when the method is called outside the Quartz Job. DB that I use is mysql.
Here is my quartz configuration from quartz.properties file.
org.quartz.scheduler.instanceName = RefundScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.threadCount = 3
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadPriority = 5
org.quartz.scheduler.skipUpdateCheck = false
Code Sample:
@Transactional
public class MyService{
@Inject
private RequestDao requestDao;
@Inject
private ResponseDao responseDao;
@Inject
private WebService webService;
public void refund(){
List<RequestEntity> requestEntity = dao.findAllForRefunding();
for(RequestEntity requestEntity : requestEntity){
ResponseEntity entity = webService.refund(requestEntity);
dao.update(entity);
}
}
}
public class RefundJob implements Job{
@Inject
private MyService service;
public void execute(JobExecutionContext jobExecutionContext) {
service.refund();
}
}