Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

transactional - Job level Transactionality in Spring Batch

I know right now there is no such thing as inter-step transactionality in Spring-Batch. I'm developing a complex batch job, with many steps performing several actions in database, and each one is related with the others, in such way that each one of them belongs to the same transaction. The way I understand the Spring-Batch paradigm I'm bound to use one-step job in order to have transactionality. Is there any thought (or any other way) to have some kind of job-level transactionality in lately or future versions?

Edit1: I have found in this link, point 6.3.1, a way to concatenate several processors, but that doesn't fulfill my current needs.

Edit2:This other link suggests me the possibility of using an envelope class with "@Transactional" annotation that will invoke my job and, therefore, shall have an external transaction.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally I have found a way to do this. As said in the last edition you must invoke the job from a transactional method:

@Transactional(propagation=Propagation.REQUIRED)

It's important set the propagation level to required in this level. And set the job level propagation to "mandatory", achieving with this the job and steps add their transactions to the current one. Nevertheless, as Michael Lange wrote, it's important to consider the potential volume size you are managing, in order to avoid out-of-the-limit commits or rollbacks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...