想要实现春季批处理交易的指数返回
基本上是标题。我正在使用JDBC项目读取器和JDBC项目编写器,并且我正在通过使用API通过处理器更改特定的状态,如果API无法更改状态,我想使用指数退回来重试此。我无法弄清楚如何实施
Basically the title. I am using a JDBC item reader and JDBC item writer and I'm changing a particular status through the processor by using an API, if the API fails to change the status, I want to use exponential backoff to retry this at a later instant. I'm not able to figure out how to implement this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有两个选项:
1。在您的项目处理器中手动处理重试操作
,基本上有两种方法可以通过编程或声明的方式来做。
1.1编程方法
您首先根据需要定义重试模板:
然后在项目处理器中使用重试模板:
1.2使用注释的声明方法
是一个示例:
2。让Spring Batch通过使用故障为您处理重试的重试-
在这种情况下,您可以在易于故障的步骤中设置自定义
retrypolicy
:请注意,在这种情况下,每当您的处理器对项目抛出一个例外时,整个块都会通过项目(每个项目都会在其自身交易中重新处理)。
上面的示例使用弹簧退休,因为您提到您偏爱这一点。但是,可以在任何其他容忍库中应用相同的想法。
You have two options:
1. Handle the retry operation manually in your item processor
There are basically two ways to do that, either programmatically or in a declarative way.
1.1 Programmatic approach
You first define your retry template with a backoff policy as needed:
Then use that retry template in your item processor:
1.2 Declarative approach using annotations
Here is an example:
2. Let Spring Batch handle the retry for you by using a fault-tolerant step
In this case, you can set a custom
RetryPolicy
in your fault-tolerant step:Note that in this case, whenever your processor throws an exception for an item, the entire chunk is retried item by item (and each item will be re-processed in its own transaction).
The examples above use spring-retry since you mentioned you have a preference for that. But the same ideas can be applied with any other fault-tolerance library.