Search code examples
springspring-mvcjbossscheduled-tasks

Disable Spring scheduling when running on jboss


We have a Spring 4 webapplication which use @EnableScheduling and @Scheduled.

On some of our testservers we don't want scheduling to be active. We have solved this by adding a profile to the configuration that have the @EnableScheduling annotation.

When running on jetty on my mac that works fine. When running on jboss (EAP 6.3) scheduling is enabled even if I delete the @EnableScheduling annotation.

Can it be something on the jboss server that turns on Spring scheduling? Any other ideas?


Solution

  • I will suggest you to control your scheduler job via property:

    @Value(..)
    private boolean enabled;
    
    @Scheduled
    public void myJob() {
      if (enabled) {
        // do things
      }
    }