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

  • Should jobLauncher.run() be called from within a transactional context?

    Hi,

    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).

    Comment

    Working...
    X