Is Spring a batch of excess

I need to upload CSV to the database once a week. Some data massaging is required since the CSV file has data for 2 tables. Therefore, I will have to process the CSV file a little, maybe convert it to 2 different CSV files and upload them to the database.

I have already configured quartz. Do you find it too difficult to use the spring package to do the job? I wonder when should I use it, and when should I just end the quartz bean to make the process itself.

+5
source share
2 answers

Spring Package is ideal for these kinds of jobs because it reduces the parts you need to take care of. In this case, all you need to do is massage the data and then paste it into two different tables. You can read the data using FileItemReader . Then use the ItemProcessor to modify any incoming data and output the correct data, correctly massed. You are supplying an ItemProcessor , as this is your custom Java logic. Then you can use JdbcItemWriter or just plug in your own.

The best part about this: [a] is super commonplace, so there are many, many examples (see Spring Package 2.0 - Part II - Flat file Into the database or joshlong / joshlong-examples / spring -batch-starter or samples in Spring for most series for inspiration) and also [b] it is mostly declarative. You do not need to worry about things that you are not interested in - you are not able to figure out how to parse CSV files correctly or even read files in a scalable manner. You just want to make sure the data is valid and make sure that it ends where it should have ended.

+6
source

Spring Batch adds additional requirements and maintenance costs:

  • You have to structure your code in String Batch in an idiomatic way (implement their interfaces).
  • You need to write several XML or Java configs - one additional DSL to learn.
  • You need an admin tool to start / stop / monitor progress. Spring Batch Admin is officially deprecated and not supported.
  • You need to maintain the BATCH_ tables, define the index strategy (by default, none), define periodic table cleanings.
  • I learned Spring Batch through debugging sessions and source code, as the documentation only touches on simple cases (e.g. CSV -> DB).
0
source

Source: https://habr.com/ru/post/1342937/


All Articles