简体   繁体   中英

How to implement the retry in spring batch 2.1.8?

We are in the process of moving to Azure SQL Server from Oracle DB for our Spring Batch application that runs for few hours with 50 Threads.

I am getting the following error intermittently

Caused by: org.springframework.dao.DataAccessResourceFailureException: Executing stored procedure; SQL [{call itemmaintenance(?, ?, ?, ?)}]; SQL Server returned an incomplete response. The connection has been closed.;

We are using spring batch 2.1.8 and I want to implement the spring retry? How do I achieve this?

To retry the spring you need to restart the dependencies to pom.xml files

<**dependency**>  <**groupId**>org.springframework.retry</**groupId**>  <**artifactId**>spring-retry</**artifactId**>  <**version**>1.2.5.RELEASE</**version**>  </**dependency**>

<**dependency**>  <**groupId**>org.springframework</**groupId**>  <**artifactId**>spring-aspects</**artifactId**>  <**version**>5.2.8.RELEASE</**version**>  </**dependency**

below sample you need to add the following to the main class.

@EnableRetry

Here are the references with related topics

DataAccessResourceFailureException (Spring Framework 5.3.16 API)

Guide to Spring Retry | Baeldung

Retry (spring.io)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM