简体   繁体   English

spring批次2.1.8如何实现重试?

[英]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.我们正在为我们的 Spring 批处理应用程序从 Oracle 数据库迁移到 Azure SQL 服务器,该应用程序使用 50 个线程运行了几个小时。

I am getting the following error intermittently我间歇性地收到以下错误

Caused by: org.springframework.dao.DataAccessResourceFailureException: Executing stored procedure;原因:org.springframework.dao.DataAccessResourceFailureException:正在执行存储过程; SQL [{call itemmaintenance(?, ?, ?, ?)}]; SQL [{call itemmaintenance(?, ?, ?, ?)}]; SQL Server returned an incomplete response. SQL 服务器返回了不完整的响应。 The connection has been closed.;连接已关闭。;

We are using spring batch 2.1.8 and I want to implement the spring retry?我们正在使用 spring 批处理 2.1.8,我想实施 spring 重试? How do I achieve this?我如何实现这一目标?

To retry the spring you need to restart the dependencies to pom.xml files要重试 spring,您需要重新启动对 pom.xml 文件的依赖项

<**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.在下面的示例中,您需要将以下内容添加到主 class。

@EnableRetry

Here are the references with related topics以下是相关主题的参考资料

DataAccessResourceFailureException (Spring Framework 5.3.16 API) DataAccessResourceFailureException (Spring Framework 5.3.16 API)

Guide to Spring Retry | Spring重试指南 | Baeldung 贝尔东

Retry (spring.io) 重试(spring.io)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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