Class SchedulerService
java.lang.Object
org.sterl.spring.persistent_tasks.scheduler.SchedulerService
Use this service if direct access to the Scheduler is required.
Note: This Service is optional, as it could be disabled if no background tasks should be execute on this note. As so the
Note: This Service is optional, as it could be disabled if no background tasks should be execute on this note. As so the
TriggerService should be preferred to queue tasks.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckIfTriggerShouldRun(TriggerAddedEvent addedTrigger) findStatus(String name) booleanlistAll()<T extends Serializable>
TriggerKeyrunOrQueue(TriggerRequest<T> triggerRequest) Runs the given trigger if a free threads are available and the runAt time is not in the future.voidsetMaxThreads(int value) voidvoidstart()voidstop()@NonNull List<Future<TriggerKey>> Simply triggers the next persistentTask which is now due to be executed@NonNull List<Future<TriggerKey>> triggerNextTasks(OffsetDateTime timeDue) LiketriggerNextTasks()but allows to set the time e.g. to the future to trigger tasks which wouldn't be triggered now.
-
Constructor Details
-
SchedulerService
public SchedulerService()
-
-
Method Details
-
start
@PostConstruct public void start() -
setMaxThreads
public void setMaxThreads(int value) -
stop
@PreDestroy public void stop() -
shutdownNow
public void shutdownNow() -
getScheduler
-
findStatus
-
triggerNextTasks
Simply triggers the next persistentTask which is now due to be executed -
triggerNextTasks
@Transactional(propagation=NEVER) public @NonNull List<Future<TriggerKey>> triggerNextTasks(OffsetDateTime timeDue) LiketriggerNextTasks()but allows to set the time e.g. to the future to trigger tasks which wouldn't be triggered now.This method should not be called in a transaction!
-
runOrQueue
@Transactional(timeout=10) public <T extends Serializable> TriggerKey runOrQueue(TriggerRequest<T> triggerRequest) Runs the given trigger if a free threads are available and the runAt time is not in the future.- Returns:
- the TriggerKey of the planned trigger
-
checkIfTriggerShouldRun
@TransactionalEventListener(phase=AFTER_COMMIT) public void checkIfTriggerShouldRun(TriggerAddedEvent addedTrigger) -
getStatus
-
rescheduleAbandonedTriggers
@Transactional public List<RunningTriggerEntity> rescheduleAbandonedTriggers(OffsetDateTime timeout) -
listAll
-
getRunning
-
getRunningTriggers
-
hasRunningTriggers
public boolean hasRunningTriggers()
-