I've been using SpringBatch for a few months now..
I used to store execution-related variables(like page count, item count, current position of a batch and so on) into Beans. Then those beans are mounted onto ItemReader
, ItemProcessor
, ItemWriter
by using setVar()
, getVar()
-setters and getters. Also those beans are shared among threads with manual synchronization.
But now I found out this could be a wrong way of doing batch jobs. Beans mounted to ItemReaders
can't be persistent in JobRepository
and therefore unable to record states for stopping and restarting of a Job. So I still need to go back and use StepExecution
/JobExecution
.
Those examples I found online are all based on either XML config, or the worse SpEL autowired to a setter method..
I use purely Java Config..Is there a Java config or Java code-oriented way of accessing StepExecution
? What's the best practice for accessing various sorts of ExecutionContext
?