1

Reading http://www.quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJobStoreCMT.html it says that JTA transactions are supported with JobStoreCMT

Is it possible to configure quartz to run with JPA transaction manager? If not I assume Atomikos or Bitronix should be used with spring to enable JTA?

Basically I want quartz scheduler to roll back if the exception is thrown e.g.

@Transactional
public void scheduleJob(QuartzJobData quartzJobData) throws Exception {

    SimpleTrigger trigger = (SimpleTrigger) newTrigger()
            .withIdentity(name, group)
            ...
            .build();

    scheduler.scheduleJob(trigger);
    throw new Exception("my exception");

    // after exception I'd expect quartz to roll back
}

Note that I don't have any problems with running transactions in quartz jobs themselves. I only have problems with quartz scheduler not rolling back as shown in code example above.

Arunas
  • 328
  • 1
  • 14
  • Possible duplicate of [Spring transaction: rollback on Exception or Throwable](https://stackoverflow.com/questions/21188239/spring-transaction-rollback-on-exception-or-throwable) – Denis Ismailovski Jun 07 '18 at 11:16
  • I think you probably need to explicitly set rollbackFor = Throwable.class – Denis Ismailovski Jun 07 '18 at 11:17
  • Denis Ismailovski I would have though that quartz is not managed by spring and propagation levels would not matter there? There could be 10s of methods in quartz before it saves the data to DB? – Arunas Jun 07 '18 at 13:56
  • I had a quick look at quartz source code and I think it creates a prepared statement in StdJDBCDelegate.selectTriggersInGroup and acquires connection in JobStoreSupport.getConnection() – Arunas Jun 07 '18 at 14:05

0 Answers0