1
votes

Currently we have a single schedule that would execute the method

@Scheduled(cron = "${SEND_SCHEDULE_1}")
public void scheduledTask() {...}

We are looking for a solution that would schedule the same task on two different times during the week, one timer for Mon-Sat and another timer for Sunday.

Is there something similar to JSR-000318 - @Schedules and @Schedule like so? @Schedules( { @Schedule(hour=”11”, dayOfWeek=”Mon-Sat”), @Schedule(hour=”10”, dayOfWeek=”Sun”) }) public void scheduledTask() { ... }

1
What spring version do you use? @Schedules exists since 4.0 - Evgeny
Oh.Cool! We are using 4.1.7. I apologize I should have thoroughly checked the documentation: docs.spring.io/spring/docs/current/javadoc-api/org/…. Thanks for the reply. - Rolly Ferolino

1 Answers

3
votes

You can use org.springframework.scheduling.annotation.Schedules

@Schedules({@Scheduled(cron=""), @Scheduled(cron="")})