Class PersistentTaskService
java.lang.Object
org.sterl.spring.persistent_tasks.PersistentTaskService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindAllTriggerByCorrelationId
(String correlationId) Returns all triggers for a correlationId sorted by the creation time.findLastTriggerByCorrelationId
(String correlationId) Returns the last knownTriggerEntity
to a given key.<T extends Serializable>
List<TriggerKey> queue
(Collection<TriggerRequest<T>> triggers) Queues/updates the given triggers, if theTriggerKey
is already present<T extends Serializable>
TriggerKeyqueue
(TriggerRequest<T> trigger) Queues/updates the given trigger, if theTriggerKey
is already present.<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.
-
Constructor Details
-
PersistentTaskService
public PersistentTaskService()
-
-
Method Details
-
getLastTriggerData
Returns the last knownTriggerEntity
to a given key. First running triggers are checked. Maybe out of the history event from a retry execution of the very same id.- Parameters:
key
- theTriggerKey
to look for- Returns:
- the
TriggerEntity
to theTriggerKey
-
getLastDetailData
-
queue
@Transactional(timeout=10) @NonNull public <T extends Serializable> List<TriggerKey> queue(Collection<TriggerRequest<T>> triggers) Queues/updates the given triggers, if theTriggerKey
is already present- Type Parameters:
T
- the state type- Parameters:
triggers
- the triggers to add- Returns:
- the
TriggerKey
-
queue
@Transactional(timeout=5) @NonNull public <T extends Serializable> TriggerKey queue(TriggerRequest<T> trigger) Queues/updates the given trigger, if theTriggerKey
is already present.- Type Parameters:
T
- the state type- Parameters:
trigger
- the trigger to add- Returns:
- the
TriggerKey
-
runOrQueue
Runs the given trigger if a free threads are available and the runAt time is not in the future.- Returns:
- the reference to the
TriggerKey
-
findAllTriggerByCorrelationId
@Transactional(readOnly=true, timeout=5) public List<TriggerEntity> findAllTriggerByCorrelationId(String correlationId) Returns all triggers for a correlationId sorted by the creation time. Data is limited to overall 300 elements.- Parameters:
correlationId
- the id to search for- Returns:
- the found
TriggerEntity
sorted by create time ASC
-
findLastTriggerByCorrelationId
@Transactional(readOnly=true, timeout=5) public Optional<TriggerEntity> findLastTriggerByCorrelationId(String correlationId)
-