Announcement Announcement Module
Collapse
No announcement yet.
How can I stop my skippable-exception-classes being retried? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I stop my skippable-exception-classes being retried?

    My writer can throw an exception which I want to skip so that the other items are written.

    If this exception is thrown I do not want to retry. I would have thought that retryable-exception-classes would retry and skippable-exception-classes would not.

    The defualt SimpleRetryPolicy is being used and it adds java.lang.Exception to the collection of retryable exceptions classes...

    public final static int DEFAULT_MAX_ATTEMPTS = 3;

    public SimpleRetryPolicy(int maxAttempts) {
    super();
    Collection<Class<? extends Throwable>> classes;
    classes = new HashSet<Class<? extends Throwable>>();
    classes.add(Exception.class);
    setRetryableExceptionClasses(classes);
    classes = new HashSet<Class<? extends Throwable>>();
    setFatalExceptionClasses(classes);
    this.maxAttempts = maxAttempts;
    }

    Can I configure my job so that it doesn't retry skipped exceptions?

    Thanks...
    Last edited by J_Rawlings; Jan 29th, 2010, 03:37 AM.

  • #2
    Skip is just the recovery from a retry, so the SimpleRetryPolicy won't work for this use case (which is definitely interesting). You need to provide a custom policy, like a ExceptionClassifierRetryPolicy.
    Last edited by Dave Syer; Jan 29th, 2010, 03:59 AM. Reason: typo

    Comment


    • #3
      Thanks Dave, is there any sample code on how I can wire in a custom policy for my writer class?

      Comment


      • #4
        I couldn't find one. You have to use the FaultTolerantStepFactoryBean to create a parent step with the policy you need. I might add this as an XML attribute before 2.1.0 goes GA.

        Comment


        • #5
          That would be good.

          Many thanks for your replies.

          Comment

          Working...
          X