Class TriggerService
java.lang.Object
org.sterl.spring.persistent_tasks.trigger.TriggerService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncancel
(Collection<TriggerKey> key) cancel
(TriggerKey key) If you changed your mind, cancel the persistentTasklong
long
countTriggers
(TaskId<?> taskId) Counts the trigger using the name only from theTaskId
long
countTriggers
(TriggerStatus status) void
org.springframework.data.domain.Page
<RunningTriggerEntity> findAllTriggers
(TaskId<?> task, org.springframework.data.domain.Pageable page) get
(TriggerKey triggerKey) boolean
Checks if any job is still running or waiting for it's execution.lockNextTrigger
(String runOn) lockNextTrigger
(String runOn, int count, OffsetDateTime timeDueAt) int
markTriggersAsRunning
(Collection<TriggerKey> keys, String runOn) markTriggersAsRunning
(RunningTriggerEntity trigger, String runOn) <T extends Serializable>
RunningTriggerEntityqueue
(TriggerRequest<T> tigger) Adds or updates an existing trigger based on itsTriggerKey
rescheduleAbandoned
(OffsetDateTime timeout) Marks any tasks which are not on the given executors/schedulers abandoned for .org.springframework.data.domain.Page
<RunningTriggerEntity> resume
(TriggerRequest<?> trigger) Will resume any foundrun
(TriggerKey triggerKey, String runningOn) The main purpose of this method is to simplify testing and run just one trigger.run
(TriggerRequest<?> request, String runningOn) run
(RunningTriggerEntity trigger) Executes the given trigger directly in the current thread and handle any errors etc.org.springframework.data.domain.Page
<TriggerGroup> searchGroupedTriggers
(TriggerSearch search, org.springframework.data.domain.Pageable page) org.springframework.data.domain.Page
<RunningTriggerEntity> searchTriggers
(TriggerSearch search, org.springframework.data.domain.Pageable page) updateRunAt
(TriggerKey key, OffsetDateTime time)
-
Constructor Details
-
TriggerService
public TriggerService()
-
-
Method Details
-
run
@Transactional(propagation=NEVER) public Optional<RunningTriggerEntity> run(@Nullable RunningTriggerEntity trigger) Executes the given trigger directly in the current thread and handle any errors etc.- Parameters:
trigger
- theRunningTriggerEntity
to run- Returns:
- the reference to the found an executed
RunningTriggerEntity
-
run
@Transactional(propagation=NEVER) public Optional<RunningTriggerEntity> run(TriggerKey triggerKey, String runningOn) The main purpose of this method is to simplify testing and run just one trigger.- Parameters:
triggerKey
- the key to trigger which should be executedrunningOn
- just any string, could be test for testing, usually the scheduler name- Returns:
- the reference to the found an executed
RunningTriggerEntity
-
run
@Transactional(propagation=NEVER) public Optional<RunningTriggerEntity> run(@Nullable TriggerRequest<?> request, String runningOn) -
markTriggersAsRunning
-
markTriggersAsRunning
-
lockNextTrigger
-
lockNextTrigger
public List<RunningTriggerEntity> lockNextTrigger(String runOn, int count, OffsetDateTime timeDueAt) -
get
-
searchTriggers
@Transactional(readOnly=true, timeout=10) public org.springframework.data.domain.Page<RunningTriggerEntity> searchTriggers(@Nullable TriggerSearch search, org.springframework.data.domain.Pageable page) -
findAllTriggers
@Transactional(readOnly=true, timeout=10) public org.springframework.data.domain.Page<RunningTriggerEntity> findAllTriggers(TaskId<?> task, org.springframework.data.domain.Pageable page) -
searchGroupedTriggers
@Transactional(readOnly=true, timeout=10) public org.springframework.data.domain.Page<TriggerGroup> searchGroupedTriggers(@Nullable TriggerSearch search, org.springframework.data.domain.Pageable page) -
deleteAll
public void deleteAll() -
hasPendingTriggers
@Transactional(readOnly=true, timeout=5) public boolean hasPendingTriggers()Checks if any job is still running or waiting for it's execution. -
queue
Adds or updates an existing trigger based on itsTriggerKey
- Type Parameters:
T
- the state type- Parameters:
tigger
- theTriggerRequest
to save- Returns:
- the saved
RunningTriggerEntity
- Throws:
IllegalStateException
- if the trigger already exists and isTriggerStatus.RUNNING
-
resume
Will resume any found- Parameters:
trigger
-- Returns:
-
cancel
If you changed your mind, cancel the persistentTask -
cancel
-
countTriggers
Counts the trigger using the name only from theTaskId
- Parameters:
taskId
- to get theTaskId.name()
- Returns:
- the amount of stored tasks
-
countTriggers
-
rescheduleAbandoned
Marks any tasks which are not on the given executors/schedulers abandoned for . Retry will be triggered based on the set strategy. -
expireTimeoutTriggers
-
countTriggers
public long countTriggers() -
updateRunAt
-