Best practice in SpringBatch
Laurent Dumas
Posted on October 8, 2021
Hi there,
I'm looking for best practice in SpringBatch like: things which are mandatory, itemReader/writer declare in the same class as job, or in a separate one..
Is there any resource on the subject? I think i may try to write some of these; I discover the subject so I need it, are people would be interested?
It seems that there's not much of it online, i'm suprised.
Edit: After reading here and there and trying myself on a sample project. I would start with these:
- Just One Job in your batch
- Log jobParameters values, startTime via (JobLoggerListener)
- Log at the end of Job (JobLoggerListener): endTime, Status of Job, ExitStatus.exitCode, and description (maybe the returnCode for the system).
- Implements a ChunkListener to see in your log the progressing of your treatment.
- Organize your listeners in differents package so you can specify appender log for example just jobListener without log all the other details. So in Production, you have a nice log with just minimum information.
- Implements an ExitCodeGenerator to return to your system a meaning code for your ops team.
- Don't use Hibernate if not necessary, prefer JdbcTemplate.
- Use a HSQLDB database for unit testing.
For books, I read the "The Definitive Guide to Spring Batch" from Michael Minella which is great to learn the framework.
💖 💪 🙅 🚩
Laurent Dumas
Posted on October 8, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.