Class DataSourceJobExecutionLogServiceImpl

java.lang.Object
org.quartzplus.service.DataSourceJobExecutionLogServiceImpl
All Implemented Interfaces:
JobExecutionLogService

public class DataSourceJobExecutionLogServiceImpl extends Object implements JobExecutionLogService
Database-backed implementation of the JobExecutionLogService using Spring's JdbcTemplate.

This service handles the persistence and retrieval of job execution history and scheduler node status using a relational database. It supports dynamic table prefixes to integrate with existing Quartz schema naming conventions.

See Also:
  • Constructor Details

    • DataSourceJobExecutionLogServiceImpl

      public DataSourceJobExecutionLogServiceImpl(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String tablePrefix)
      Constructs a new service instance with a specified template and table prefix.
      Parameters:
      jdbcTemplate - the JDBC template used for database operations.
      tablePrefix - the prefix for Quartz and QuartzPlus tables (e.g., "QRTZ_").
  • Method Details

    • getJobExecutionLogList

      public org.springframework.data.domain.Page<JobExecutionLog> getJobExecutionLogList(Integer pageSize, Integer currentPage, @Nullable String groupName, @Nullable String jobName, @Nullable String triggerName, @Nullable String instanceClass)
      Retrieves a paged list of job execution logs filtered by optional criteria.

      Results are returned in descending order of creation time.

      Specified by:
      getJobExecutionLogList in interface JobExecutionLogService
      Parameters:
      pageSize - number of records per page.
      currentPage - the zero-based page index.
      groupName - (Optional) filter by job group name.
      jobName - (Optional) filter by job name.
      triggerName - (Optional) filter by trigger name.
      instanceClass - (Optional) filter by the job's implementation class name.
      Returns:
      a Page containing the requested logs and total count.
    • getJobExecutionLog

      public Optional<JobExecutionLog> getJobExecutionLog(String jobExecutionLogId)
      Fetches a specific job execution log by its unique identifier.
      Specified by:
      getJobExecutionLog in interface JobExecutionLogService
      Parameters:
      jobExecutionLogId - the UUID or unique ID of the log entry.
      Returns:
      an Optional containing the log if found, or empty otherwise.
    • insertJobExecutionLog

      public void insertJobExecutionLog(JobExecutionLog jobExecutionLog)
      Persists a new job execution log entry into the database.
      Specified by:
      insertJobExecutionLog in interface JobExecutionLogService
      Parameters:
      jobExecutionLog - the log data to insert.
    • clearJobExecutionLog

      public int clearJobExecutionLog(Instant until)
      Deletes log entries created before the specified timestamp.
      Specified by:
      clearJobExecutionLog in interface JobExecutionLogService
      Parameters:
      until - the cutoff timestamp for deletion.
      Returns:
      the number of records deleted.
    • getQuartzExecutionNodeList

      public List<QuartzExecutionNode> getQuartzExecutionNodeList()
      Retrieves the status of all registered Quartz scheduler nodes in the cluster. Reads from the SCHEDULER_STATE table.
      Specified by:
      getQuartzExecutionNodeList in interface JobExecutionLogService
      Returns:
      a list of QuartzExecutionNode objects.
    • getTablePrefix

      public String getTablePrefix()
      Returns the database table prefix used by this service.
      Specified by:
      getTablePrefix in interface JobExecutionLogService
      Returns:
      the table prefix string.