Announcement Announcement Module
Collapse
No announcement yet.
Fixing data and retrying Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fixing data and retrying

    Hi everybody,

    I have a question regarding chunk retrying on exception.

    My use case is as follows: I have a directory to which an external process writes files. A listener listens to the directory and starts a corresponding job according to a file name pattern when it appears there. A job reads a file and writes the data via iBatis DAO to the database. The used spring-batch version is 1.0.0.m3.
    When I run my job with correct test data files and no exceptions are thrown everything works perfectly.
    I have a problem with data files that contain incorrect data. When I get an SQLException (a contraint reference in this case) I want to fix the problem (update another table) and rerun the latest record (fieldset) insert.
    I use DefaultStepExecutor with RestartableItemProviderTasklet, SimpleStepConfiguration with SimpleLimitExceptionHandler. In JobConfiguration restartable = true. In my implementation of AbstractItemProvider I tried to override the recover(java.lang.Object o, java.lang.Throwable throwable) method that returns true, and even tried to implement the Skippable interface in the same provider class. But both of them cause the flow to enter into an endless recursion. In general there are 2 cases: one is to fix the problem and retry, and the second is to skip the problematic record (each cause has its corresponding exception, of course).
    So my question is how should I implement such a behavior? And how can I get to the problematic record that I want to change?

    Any help is highly appriciated.
    Alex.

  • #2
    The callback to recover() will only happen if you set a RetryPolicy on the step. It sounds from your example as if you need a policy that never retries (or at least never the exception that you want to recover from).

    I'm not sure how implementing Skippable (or ItemRecoverer) could generate an infinite loop. You need to provide more details for us to debug that problem.

    Comment


    • #3
      Thank you for your help

      Dave, thank you very much. You were right as to the policy. I used NeverRetryPolicy and it did the trick. Now I'm able to get the wrong record and skip it without any problem. All the correct records in the same chunk are saved correctly as expected.
      Once again thank you for your help.

      Comment

      Working...
      X