Questions tagged [spring-scheduled]

Refers to the org.springframework.core.task package of the Spring Framework that is concerned with task scheduling and execution.

Javadoc here: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/task/package-summary.html

459 questions
293
votes
6 answers

Spring cron expression for every day 1:01:am

I'm trying to have my code execute on a fixed schedule, based on a Spring cron expression. I would like the code to be executed every day at 1:01:am. I tried the following expression, but this didn't fire up for me. What's wrong with the syntax…
d-man
  • 57,473
  • 85
  • 212
  • 296
141
votes
11 answers

Spring Scheduled Task running in clustered environment

I am writing an application that has a cron job that executes every 60 seconds. The application is configured to scale when required onto multiple instances. I only want to execute the task on 1 instance every 60 seconds (On any node). Out of the…
user3131879
  • 1,605
  • 2
  • 12
  • 11
101
votes
8 answers

Scheduling a job with Spring programmatically (with fixedRate set dynamically)

Currently I have this : @Scheduled(fixedRate=5000) public void getSchedule(){ System.out.println("in scheduled job"); } I could change this to use a reference to a property @Scheduled(fixedRateString="${myRate}") public void getSchedule(){ …
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
48
votes
2 answers

How to prevent overlapping schedules in Spring?

@Scheduled(fixedDelay = 5000) public void myJob() { Thread.sleep(12000); } How can I prevent this spring job from running if the previous routine is not yet finished?
membersound
  • 81,582
  • 193
  • 585
  • 1,120
34
votes
6 answers

Injecting externalized value into Spring annotation

I've been thinking around the Java feature that evaluates annotation values in compile-time and it seems to really make difficult externalizing annotation values. However, I am unsure whether it is actually impossible, so I'd appreciate any…
quantum
  • 3,000
  • 5
  • 41
  • 56
23
votes
8 answers

Spring @Scheduled annotation random delay

I am using the @Scheduled annotation from Spring framework to invoke a method. But I have multiple nodes in my setup and I do not want them to all run at exactly the same time. So I'd like to set a random value to the initial delay to offset them…
troymass
  • 1,022
  • 3
  • 11
  • 24
22
votes
5 answers

Universal exception handler for @Scheduled tasks in Spring (Boot) with Java configuration

I have lots of scheduled tasks in my Spring Boot (ver 1.4.2) application and would like to catch all exceptions from them using one handler like is possible for normal controllers with @ExceptionHandler annotation. This approach does not work for…
MF.OX
  • 2,366
  • 1
  • 24
  • 28
21
votes
1 answer

Difference between Quartz Job and Scheduling Tasks with Spring?

I am new to Spring-boot(version 1.3.6) and Quartz and I am wondering what is the difference between making a task with Spring-scheduler: @Scheduled(fixedRate = 40000) public void reportCurrentTime() { System.out.println("Hello…
Xelian
  • 16,680
  • 25
  • 99
  • 152
19
votes
7 answers

Disable @Schedule on Spring Boot IntegrationTest

How can I disable the schedule auto-start on Spring Boot IntegrationTest? Thanks.
fassoline
  • 191
  • 1
  • 1
  • 6
19
votes
3 answers

Exception handling for Spring 3.2 "@Scheduled" annotation

How to customize the exception handling for @Scheduled annotation from spring ? I have Cron jobs which will be triggered in the server (Tomcat 6) and when any exceptions occur I need to do some handling. Spring version 3.2 Tomcat Server 6
user3515080
  • 545
  • 2
  • 6
  • 17
17
votes
3 answers

stop Spring Scheduled execution if it hangs after some fixed time

I have used Spring Framework's Scheduled to schedule my job to run at every 5 mins using cron. But sometime my job waits infinitely for an external resource and I can't put timeout there. I can't use fixedDelay as previous process sometime goes in…
Shams
  • 3,637
  • 5
  • 31
  • 49
14
votes
1 answer

Is it possible to call a spring scheduled method manually

Is there a way to call a spring scheduled method (job) through a user interaction? I need to create a table with shown all jobs and the user should be able to execute them manually. For sure the jobs run automatically but the user should be able to…
Nkalian
  • 141
  • 1
  • 1
  • 5
14
votes
4 answers

cron expression parsing into java date

my database having 10 18 16 ? * SUN,MON,WED,FRI * cron expression then how to convert into Java date. how to comparing with present day time. and one more is how to compare to cron expressions i.e. 10 18 16 ? * SUN,MON,WED,FRI * and 0 30 9 30 *…
user3599212
  • 429
  • 2
  • 6
  • 18
14
votes
1 answer

spring scheduled task run every second with cron(0 0/10 * * * ? )

it's strange, i setup corn as @Scheduled(cron= "0 0/10 * * * ? ") It did trigger every 10 minutes, but the issue is task runs each second.
Paris Tao
  • 335
  • 1
  • 3
  • 11
13
votes
2 answers

Schedule a task with Cron which allows dynamic update

I use sprint boot 1.3, spring 4.2 In this class @Service public class PaymentServiceImpl implements PaymentService { .... @Transactional @Override public void processPayment() { List payments =…
robert gagnon
  • 311
  • 1
  • 5
  • 14
1
2 3
30 31