Announcement Announcement Module
No announcement yet.
Should be called from within a transactional context? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Should be called from within a transactional context?


    I don't think I'm doing anything too wrong, but with the AOP stuff flying around, I'm a little uncertain of what's going on...

    I have a SimpleJobLauncher that uses an SimpleAsyncTaskExecutor. The SimpleJobLauncher is configured to get its JobRepository from a JobRepositoryFactoryBean that has a dataSource, transactionManager, etc.

    I have a Controller that is not listed in my TransactionAutoProxyCreator that I used to apply TransactionInterceptors.

    In the onSubmit of the Controller, it uses the jobLauncher to launch a new job. No @Transactional annotation surrounds the call to jobLauncher (and even if there was the annotation, it wouldn't matter because, like I said, I'm not proxying the controller).

    Is that ok?

    If I understand the architecture correctly, the jobLauncher uses its own DAOs to register a new JobExecution object and takes care of all the exceptions/rollbacks/whatever that may occur in the act of even getting the job registered.

    Once registered, the individual Steps within the Job handle their own transactions based on whether or not they're "simple", "chunked", "fault tolerant", etc.

    Is that right?

  • #2
    Yes. Running a Job inside a transaction actually causes issues (i.e. it is not supported, but not detected at present either, so we can't warn or fail if you do it by mistake).