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 first info to a trigger based on the correlationId.Returns the last knownTriggerData
to a given key.<T extends Serializable>
List<TriggerKey> queue
(Collection<AddTriggerRequest<T>> triggers) Queues/updates the given triggers, if theTriggerKey
is already present<T extends Serializable>
TriggerKeyqueue
(AddTriggerRequest<T> trigger) Queues/updates the given trigger, if theTriggerKey
is already present.<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.
-
Constructor Details
-
PersistentTaskService
public PersistentTaskService()
-
-
Method Details
-
getLastTriggerData
Returns the last knownTriggerData
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
TriggerData
to theTriggerKey
-
getLastDetailData
-
queue
@Transactional(timeout=10) @NonNull public <T extends Serializable> List<TriggerKey> queue(Collection<AddTriggerRequest<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(AddTriggerRequest<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<TriggerData> 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
TriggerData
sorted by create time ASC
-
findLastTriggerByCorrelationId
@Transactional(readOnly=true, timeout=5) public Optional<TriggerData> findLastTriggerByCorrelationId(String correlationId) Returns the first info to a trigger based on the correlationId.- Parameters:
correlationId
- the id to search for- Returns:
- the found
TriggerData
-