Transaction Management Questions

I am trying to implement a business task using Spring and have some problems with transaction management.

Business need, simply,
1) Request a database (No. 1) with some criteria.
2) Record the query results in a flat file.
3) Update these records in the database (# 1) as "processed".
4) Insert records into another database (# 2) as a result of the first three steps.

I need these 4 steps to be translational. For example, if the 4th step fails, the last item written to the flat file in the second step should be rolled back. I found the "Apache Commons File Resource Manager" to implement a rollback mechanism with files.

My mentor recommended that I use the Spring Package in general for such projects. However, given the fact that Spring Batch uses the "chunk oriented processing" processing style, it is quite difficult to implement it using Spring Batch. Since, as far as I know, the piece-oriented style requires that the second step be completed for the whole fragment, and then it allows you to go to the 3rd and 4th steps in my implementation.

I think I need to give general advice on this project and whether or not to use Spring Batch for this purpose. In addition, it would be nice to try to meet these needs in a parallel environment, since the rollback mechanism will be quite complicated for this style.

+3
source share
2 answers

, , , , ( ). Spring batch - , , Spring, . Spring . , , Spring.

, , , :

  • , db # 2

, . , , . , Spring batch:

  • , . . Spring Batch. Spring .
  • Spring , 1. db.
  • - . Spring , , . : db # 1 . 4 , , , .

Spring , , , , , .

, .. , . , -, , .

, , , Spring . , . .

, .

+3

, Spring - Flat File Spring PlatformTransactionManager , , . .

0

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


All Articles