Class Job

All Implemented Interfaces:
Lockable

public class Job extends AbstractJob
Defines the job with its JobDetails, History and Job Metadata. Note: Jobs are managed by JobRunr and may under no circumstances be updated during Job Processing. They may be deleted though.

During Job Processing, JobRunr updates the job every x amount of seconds (where x is the pollIntervalInSeconds and defaults to 15s) to distinguish running jobs from orphaned jobs (orphaned jobs are jobs that have the state in PROGRESS but are not running anymore due to JVM or container crash).

  • Field Details

  • Constructor Details

  • Method Details

    • newUUID

      public static UUID newUUID()
    • getId

      public UUID getId()
      Specified by:
      getId in class AbstractJob
    • setRecurringJobId

      public void setRecurringJobId(String recurringJobId)
    • getRecurringJobId

      public Optional<String> getRecurringJobId()
    • getJobStates

      public List<JobState> getJobStates()
    • getJobStatesOfType

      public <T extends JobState> Stream<T> getJobStatesOfType(Class<T> clazz)
    • getLastJobStateOfType

      public <T extends JobState> Optional<T> getLastJobStateOfType(Class<T> clazz)
    • getJobState

      public <T extends JobState> T getJobState()
    • getJobState

      public JobState getJobState(int element)
    • getState

      public StateName getState()
    • hasState

      public boolean hasState(StateName state)
    • hasStateChange

      public boolean hasStateChange()
    • getStateChangesForJobFilters

      public List<JobState> getStateChangesForJobFilters()
      This method is only to be called by JobRunr itself. It may not be called externally as it will break the JobFilters
      Returns:
      all the stateChanges since they were last retrieved.
    • enqueue

      public void enqueue()
    • scheduleAt

      public void scheduleAt(Instant instant, String reason)
    • startProcessingOn

      public void startProcessingOn(BackgroundJobServer backgroundJobServer)
    • updateProcessing

      public Job updateProcessing()
    • succeeded

      public Job succeeded()
    • failed

      public Job failed(String message, Exception exception)
    • delete

      public Job delete(String reason)
    • getCreatedAt

      public Instant getCreatedAt()
    • getUpdatedAt

      public Instant getUpdatedAt()
    • getMetadata

      public Map<String,Object> getMetadata()
    • toString

      public String toString()
      Overrides:
      toString in class Object