Logo

dev-resources.site

for different kinds of informations.

Best practice in SpringBatch

Published at
10/8/2021
Categories
springbatch
springboot
batchprocessing
Author
laurentld79
Author
11 person written this
laurentld79
open
Best practice in SpringBatch

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.

Featured ones: