Class PersistentTaskService

java.lang.Object
org.sterl.spring.persistent_tasks.PersistentTaskService

@Service public class PersistentTaskService extends Object
Abstraction to SchedulerService or TriggerService depends on if the SchedulerService is available.
  • Constructor Details

    • PersistentTaskService

      public PersistentTaskService()
  • Method Details

    • getLastTriggerData

      public Optional<TriggerData> getLastTriggerData(TriggerKey key)
      Returns the last known TriggerData 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 - the TriggerKey to look for
      Returns:
      the TriggerData to the TriggerKey
    • getLastDetailData

      public Optional<TriggerData> getLastDetailData(TriggerKey key)
    • queue

      @Transactional(timeout=10) @NonNull public <T extends Serializable> List<TriggerKey> queue(Collection<AddTriggerRequest<T>> triggers)
      Queues/updates the given triggers, if the TriggerKey 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 the TriggerKey is already present.
      Type Parameters:
      T - the state type
      Parameters:
      trigger - the trigger to add
      Returns:
      the TriggerKey
    • runOrQueue

      public <T extends Serializable> TriggerKey runOrQueue(AddTriggerRequest<T> triggerRequest)
      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