Friday, May 9, 2014

Manually Execute a Spring @Scheduled method

I have to admit I'm a little disappointed that there isn't an easy way to hook into Spring's @Scheduled jobs like there is with Quartz jobs.  I expected there to be some way to get the list of scheduled jobs but after digging through the ScheduledAnnotationBeanPostProcessor it doesn't look like they make that data visible.

So, here is a way to execute a method annotated with the @Scheduled annotation.  And, for the record, I don't like having to manually create Spring beans, loop through methods, or any of the other smelly things that are going on here.

The BaseAjaxResponse is simply a pojo that gets converted into json (see SpringMVC and jackson)


  1. Please, vote for this issue: to create an easy-way to do this.

  2. Why not inject the bean with @Scheduled methods and just call them? What is the value of this approach?

  3. Hi before invoke method if call shutdown then call invoke method scheduler class losing scheduled character

    do you know why ?