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 TypeMethodDescriptionvoid
checkIfTriggerShouldRun
(TriggerAddedEvent addedTrigger) findStatus
(String name) boolean
listAll()
rescheduleAbandonedTasks
(OffsetDateTime timeout) <T extends Serializable>
TriggerKeyrunOrQueue
(AddTriggerRequest<T> triggerRequest) Runs the given trigger if a free threads are available and the runAt time is not in the future.void
setMaxThreads
(int value) void
void
start()
void
stop()
Simply triggers the next persistentTask which is now due to be executedtriggerNextTasks
(OffsetDateTime timeDue) LiketriggerNextTasks()
but allows to set the time e.g.
-
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) @NonNull public 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(AddTriggerRequest<T> triggerRequest) Runs the given trigger if a free threads are available and the runAt time is not in the future.- Returns:
- the reference to the
Future
with the key, if no threads are available it is resolved
-
checkIfTriggerShouldRun
@TransactionalEventListener(phase=AFTER_COMMIT) public void checkIfTriggerShouldRun(TriggerAddedEvent addedTrigger) -
getStatus
-
rescheduleAbandonedTasks
-
listAll
-
getRunning
-
getRunningTriggers
-
hasRunningTriggers
public boolean hasRunningTriggers()
-