Announcement Announcement Module
Collapse
No announcement yet.
Retry in a Tasklet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retry in a Tasklet

    In Spring batch 2.04, I made a simple tasklet become retryable through AOP by customizing the SimpleRetryPolicy in which it did more works like sending email alert if it reached the maxAttemp. But the method setRetryableExceptionClasses() doesn't work anymore in v2.1.2 because the setTypes() is not available in BinaryExceptionClassifier. So, how can I configure a list retryable exception classes in my customized RetryPolicy? Thanks.

  • #2
    BinaryExceptionClassifier has a wide variety of constructors. Can't you use one of those?

    Comment


    • #3
      You're right, Dave. I can use the constructor taking a collection of exception classes. It works now. The only thing is that the email alert I coded in canRetry() will repeat multiple times. So, I'm wondering where is the best place I could do this kind of customization, create my own RetryTemplate? Thanks.

      Comment


      • #4
        I don't really know what your customization is, so I can't say what the best way to implement it is. Did you look at RetryInterceptor and RecoveryCallback?

        Comment


        • #5
          I'm trying to make it sending out email alerts when the number of attempt reach certain threshold or the maximum. So I created a class similar like SimpleRetryPolicy to implement my own logic in canRetry method. The only drawback is that it sends email multiple times because new version of RetryTemplate call canRetry two times. I think the following code is redundant in RetryTemplate because it's the same condition for the while loop.
          Code:
           if (canRetry(retryPolicy, context) && !context.isExhaustedOnly())
          Also it would be ideal if I could inject StepExecution to my RetryPolicy to get the job name and parameters in the email alert. Is it possible?

          Comment

          Working...
          X