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 knownTriggerEntityto a given key.<T extends Serializable>
List<TriggerKey> queue(Collection<TriggerRequest<T>> triggers) Queues/updates the given triggers, if theTriggerKeyis already present<T extends Serializable>
TriggerKeyqueue(TriggerRequest<T> trigger) Queues/updates the given trigger, if theTriggerKeyis 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 knownTriggerEntityto 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- theTriggerKeyto look for- Returns:
- the
TriggerEntityto theTriggerKey
-
queue
@Transactional(timeout=10) @NonNull public <T extends Serializable> List<TriggerKey> queue(Collection<TriggerRequest<T>> triggers) Queues/updates the given triggers, if theTriggerKeyis 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 theTriggerKeyis 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
TriggerEntitysorted by create time ASC
-
findLastTriggerByCorrelationId
@Transactional(readOnly=true, timeout=5) public Optional<TriggerEntity> findLastTriggerByCorrelationId(String correlationId) -
getLastTriggerHistory
-