MasterCode
MasterCode

Reputation: 995

Spring Task Scheduler

I know about spring task scheduler works with fixed delay by using @Scheduled(fixedDelay=1000) and @Scheduled(fixedRate=2000) but what If I want to execute certain task after 15 minutes from know. Is there any such Trigger that I can use to each that functinality? Scenario Like: if I want to execute it after 15 minutes and when I am excecuting after 15minutes I will decide if I want to execute again after 15 minutes not for every 15 minutes of delay

Upvotes: 0

Views: 1080

Answers (1)

Ammar
Ammar

Reputation: 4024

You need to use intialDelay along with fixedDelay or fixedRate.

@Scheduled(fixedDelay = 2000 , initialDelay = 900000) // first execution would be after 900000 ms or 15 minutes

See relevant docs here

Upvotes: 1

Related Questions