peppo
peppo

Reputation: 21

launch job from step in spring batch

I am trying to launch a job from inside a step (the execute method of a class implementing the interface Tasklet).

Obviously i received the exception

java.lang.IllegalStateException: Existing transaction detected in JobRepository

How to make a spring batch step not transactional?

Does anyone have a solution to my main need of launching a job from inside a step?

Thanks in advance for the help!

Upvotes: 1

Views: 1891

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31590

How to make a spring batch step not transactional?

You can set a ResourcelessTransactionManager on your step. Think of it as a NoOp transaction manager.

Does anyone have a solution to my main need of launching a job from inside a step?

The JobStep is specifically designed for this use case. It is a Step implementation that delegates to a Job.

Hope this helps.

Upvotes: 1

Related Questions