简体   繁体   English

具有可重试和可跳过异常的jsr 352批处理可能会多次处理项目

[英]jsr 352 batch with retryable and skippable exception may processes items many times

I have a batch implemented with JSR-352 (using jberet on wildfly). 我有一个用JSR-352实现的批处理(在wildfly上使用jberet)。

I have a chunk with item-count 15 and java.lang.Exception is configured as retryable and skippable exception. 我有一个item-count 15的块, java.lang.Exception被配置为可重试和可跳过的异常。

When there are many exceptions, most of the items will be processed multiple times. 当有许多例外情况时,大多数项目将被多次处理。 In this extreme case all items would throw an exception in the writer: 在这种极端情况下,所有项目都会在编写器中抛出异常:

  • First 15 items are read 前15个项目被阅读
  • Exception occurs on first item 第一项上发生异常
  • Chunk is rolled back and configured with item-count = 1 回滚块并使用item-count = 1进行配置
  • First item is read 读取第一项
  • Exception occurs again, item is skipped 再次发生异常,跳过项目
  • Proceed with the other 14 items, exception may occur on every item, every item is skipped 继续执行其他14个项目,每个项目都可能发生异常,每个项目都会被跳过
  • After the first 15 items the chunk is back with item-count = 15 在前15个项目之后,块返回,item-count = 15
  • Items 16-30 are read 读取项目16-30
  • Exception occurs again 异常再次发生
  • Reader is rolled back to latest checkpoint Reader将回滚到最新的检查点

At this point there is still no checkpoint because there was no successful processed item yet. 此时仍然没有检查点,因为尚未成功处理项目。 Hence the reader starts with the first item again. 因此,读者再次从第一个项目开始。 All 30 items are processed with item-count = 1. etc. 使用item-count = 1等处理所有30个项目。

If there are many such failures the batch would process all items again and again. 如果存在许多此类故障,批次将一次又一次地处理所有项目。

I think the checkpoint needs to be set also for skipped items because a skipped item should not be processed again. 我认为还需要为跳过的项设置检查点,因为不应再次处理跳过的项。

I think this is a bug in the specification so I already opened an issue there: https://github.com/WASdev/standards.jsr352.batch-spec/issues/15 Or am I wrong and have misunderstood the implementation? 我认为这是规范中的一个错误所以我已经在那里打开了一个问题: https//github.com/WASdev/standards.jsr352.batch-spec/issues/15或者我错了并误解了实现?

How is this implemented in Spring Batch? 如何在Spring Batch中实现?

I think the specification is clear enough, which suggests this could be a JBeret bug (assuming it's not an application issue). 我认为规范足够清楚,这表明这可能是一个JBeret错误(假设它不是应用程序问题)。

In the spec (an unofficial version here ), the section: 在规范( 这里的非官方版本)中,该部分:

8.2.1.4.3 Retry and Skip the Same Exception 8.2.1.4.3重试并跳过相同的异常

says that during a retry with rollback, the items are processed one-at-a-time, (in one-item chunks), and that skip takes precedence during retry. 表示在使用回滚重试期间,一次一个地处理项目(在单项目块中),并且在重试期间跳过优先级。

So if a skippable exception occurs during retry, that item would just be skipped, and an updated checkpoint should be persisted. 因此,如果在重试期间发生可跳过的异常,则只会跳过该项,并且应该保留更新的检查点。 This is how WebSphere Liberty Batch , the JSR 352 implementation I work on, does it. 这就是WebSphere Liberty Batch (我工作的JSR 352实现)的工作方式。

So I'd suggest producing a recreate project and opening a JBeret issue if it still looks like one. 所以我建议生成一个重新创建项目并打开一个JBeret问题,如果它仍然像一个。 At this point, I don't see a spec issue. 此时,我没有看到规格问题。

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

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