Spring Framework
  1. Spring Framework
  2. SPR-6860

Ability to configure retry on scheduled tasks either in annotation on in XML config

    Details

    • Type: Improvement Improvement
    • Status: Waiting for Feedback
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0 GA
    • Fix Version/s: General Backlog
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      I've recently deployed an application with a scheduled task that used a required JPA-enhanced class that was mistakenly not listed in the persistence.xml file. An exception is thrown when the method is run - as expected, but the exception is thrown ~ 10,000 times. It appears that this is because some kind of re-try behavior in the tasks scheduler.

      If I'm correct about this, it would be convenient to be able to set a number of times to re-try a method that throws an exception during a scheduled task.

        Activity

        Hide
        Mark Fisher added a comment -

        Dave, I'm re-assigning this one to you, because it most likely overlaps with the addition of RetryTemplate (applying that to scheduled tasks).

        Show
        Mark Fisher added a comment - Dave, I'm re-assigning this one to you, because it most likely overlaps with the addition of RetryTemplate (applying that to scheduled tasks).
        Hide
        Dave Syer added a comment -

        If this was really about retry I would say have a look at http://github.com/SpringSource/spring-retry, but if I understand the use case it's more of a problem of not being able to stop the task. (The "retry behaviour" in the description of this issue is just the task scheduler blindly executing the task according to the trigger you gave it, and faithfully logging the result.) You can declare an error handler with a scheduled task, so maybe a solution would be to detect obvious fatal errors and shutdown the ScheduledExecutorService, and even send a signal to some other business component that can decide whether the application itself has to shut down.

        It would be nice to be able to cancel the specific Runnable that has failed, and I'm not sure you can do that with Spring 3.0 because only the ScheduledTaskRegistrar has a reference to it. Would it help if you could do that in Spring 3.1? I think that would only be a nice to have.

        Can you confirm this analysis, so I can change the issue summary to more accurately reflect the use case?

        Show
        Dave Syer added a comment - If this was really about retry I would say have a look at http://github.com/SpringSource/spring-retry , but if I understand the use case it's more of a problem of not being able to stop the task. (The "retry behaviour" in the description of this issue is just the task scheduler blindly executing the task according to the trigger you gave it, and faithfully logging the result.) You can declare an error handler with a scheduled task, so maybe a solution would be to detect obvious fatal errors and shutdown the ScheduledExecutorService, and even send a signal to some other business component that can decide whether the application itself has to shut down. It would be nice to be able to cancel the specific Runnable that has failed, and I'm not sure you can do that with Spring 3.0 because only the ScheduledTaskRegistrar has a reference to it. Would it help if you could do that in Spring 3.1? I think that would only be a nice to have. Can you confirm this analysis, so I can change the issue summary to more accurately reflect the use case?

          People

          • Assignee:
            Dave Syer
            Reporter:
            Matt Young
            Last updater:
            Trevor Marshall
          • Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              2 years, 46 weeks, 6 days ago