0

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();
  }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • How have you wired this together? When and how is `RefundJob` injected by guice? – eiden May 16 '13 at 00:46
  • well I'am using the [guartz](http://99soft.github.io/guartz/userguide.html) extension of quartz, which is implementation of quartz and guice together. And the service is bind into the quartzModule. – Nikola Ivanov May 17 '13 at 08:32
  • And what are you using for persistence? Hibernate? – eiden May 17 '13 at 09:20

0 Answers0