如何以编程方式为Spring Tasklet(而非块)配置容错 [英] How to configure fault tolerance programmatically for a spring tasklet (not a chunk)

查看:120
本文介绍了如何以编程方式为Spring Tasklet(而非块)配置容错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以编程方式为块配置容错的工作方式如下:

Programmatically configuring fault tolerance for a chunk works kind of as follows:

stepBuilders.get("step")
  .<Partner,Partner>chunk(1)
  .reader(reader())
  .processor(processor())
  .writer(writer())
  .listener(logProcessListener())
  .faultTolerant()
  .skipLimit(10)
  .skip(UnknownGenderException.class)
  .listener(logSkipListener())
  .build();

诀窍是,通过添加块",链切换到提供"faultTolerant"方法的SimpleStepBuilder.

The trick is, that with adding "chunk", the chain switches to a SimpleStepBuilder which offers the "faultTolerant" method.

我的问题是,如果您只有一个Tasklet(没有读取器,处理器,写入器),该怎么办?

My question is how to do that if you just have a tasklet (no reader, processor, writer)?

定义小任务的工作方式如下:

Defining a tasklet works as follows:

stepBuilders.get("step")
  .tasklet(tasklet())
  .build();

"tasklet"的用法切换到不提供"faultTolerant"方法的TaskletStepBuilder.因此,我看不到如何定义诸如skipLimit之类的属性.

The usage of "tasklet" switches to a TaskletStepBuilder which does not offer a "faultTolerant" method. Therefore I see no way how to define properties like skipLimit and that like.

有什么想法吗?

推荐答案

Tasklet没有要跳过的项目"概念,因此容错仅对面向块的步骤有意义.我建议您在原始代码中使用Spring Retry(1.1.0.RELEASE现在已经发布,并且您有一些流畅的生成器选项和@Retryable批注).

A Tasklet has no notion of "items" to skip, so fault tolerance only makes sense for a chunk-oriented step. I suggest you use Spring Retry in the raw (1.1.0.RELEASE is out now, just, and you have some fluent builder options and a @Retryable annotation there).

这篇关于如何以编程方式为Spring Tasklet(而非块)配置容错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆