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
<TriggerEntity> findAllTriggers
(TaskId<?> task, org.springframework.data.domain.Pageable page) org.springframework.data.domain.Page
<TriggerEntity> findAllTriggers
(TriggerKey key, TriggerStatus status, org.springframework.data.domain.Pageable page) findTriggerByCorrelationId
(String correlationId, 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
(TriggerEntity trigger, String runOn) <T extends Serializable>
TriggerEntityqueue
(AddTriggerRequest<T> tigger) Adds or updates an existing trigger based on itsTriggerKey
rescheduleAbandonedTasks
(OffsetDateTime timeout) Marks any tasks which are not on the given executors/schedulers abandoned for .run
(AddTriggerRequest<?> request, String runningOn) run
(TriggerKey triggerKey, String runningOn) The main purpose of this method is to simplify testing and run just one trigger.run
(TriggerEntity trigger) Executes the given trigger directly in the current thread and handle any errors etc.updateRunAt
(TriggerKey key, OffsetDateTime time)
-
Constructor Details
-
TriggerService
public TriggerService()
-
-
Method Details
-
run
@Transactional(propagation=NEVER) public Optional<TriggerEntity> run(@Nullable TriggerEntity trigger) Executes the given trigger directly in the current thread and handle any errors etc.- Parameters:
trigger
- theTriggerEntity
to run- Returns:
- the reference to the found an executed
TriggerEntity
-
run
@Transactional(propagation=NEVER) public Optional<TriggerEntity> 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
TriggerEntity
-
run
@Transactional(propagation=NEVER) public Optional<TriggerEntity> run(@Nullable AddTriggerRequest<?> request, String runningOn) -
markTriggersAsRunning
-
markTriggersAsRunning
-
lockNextTrigger
-
lockNextTrigger
-
get
-
findAllTriggers
@Transactional(readOnly=true, timeout=10) public org.springframework.data.domain.Page<TriggerEntity> findAllTriggers(@Nullable TriggerKey key, @Nullable TriggerStatus status, org.springframework.data.domain.Pageable page) -
findAllTriggers
@Transactional(readOnly=true, timeout=10) public org.springframework.data.domain.Page<TriggerEntity> findAllTriggers(TaskId<?> task, 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
- theAddTriggerRequest
to save- Returns:
- the saved
TriggerEntity
- Throws:
IllegalStateException
- if the trigger already exists and isTriggerStatus.RUNNING
-
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
-
rescheduleAbandonedTasks
Marks any tasks which are not on the given executors/schedulers abandoned for . Retry will be triggered based on the set strategy. -
countTriggers
public long countTriggers() -
updateRunAt
-
findTriggerByCorrelationId
public List<TriggerEntity> findTriggerByCorrelationId(String correlationId, org.springframework.data.domain.Pageable page)
-