Home

Awesome

db-scheduler-log

build status Maven Central License

Getting started

  1. Add maven dependency

<dependency>
    <groupId>io.rocketbase.extension</groupId>
    <artifactId>db-scheduler-log</artifactId>
    <version>${version}</version>
</dependency>
  1. Create the scheduled_execution_logs table in your database-schema. See table definition for postgresql, oracle, mssql or mysql.

:mega: It's highly recommended to create the log-table with daily partitions based on time_started with a proper retention when you have a huge amount of running tasks... otherwise you could run out of disk-space quite soon.

  1. Customize the scheduler to use extended StatsRegistry.
final JdbcLogRepository jdbcLogRepository=new JdbcLogRepository(dataSource,new JavaSerializer(),JdbcLogRepository.DEFAULT_TABLE_NAME,new Snowflake());

final Scheduler scheduler=Scheduler
        .create(dataSource)
        .startTasks(hourlyTask)
        .threads(5)
        .statsRegistry(new LogStatsPlainRegistry(jdbcLogRepository))
        .build();

Spring Boot usage

For Spring Boot applications, there is a starter db-scheduler-log-spring-boot-starter making the scheduler-log-wiring very simple.

Prerequisites

Getting started

  1. Add the following Maven dependency
    <dependency>
        <groupId>io.rocketbase.extension</groupId>
        <artifactId>db-scheduler-log-spring-boot-starter</artifactId>
        <version>${version}</version>
    </dependency>
    
    NOTE: This includes the db-scheduler-spring-boot-starter dependency itself.
  2. Do configuration explained on db-scheduler... 3Run the app.

Configuration options

Configuration is mainly done via application.properties. Configuration of table-name is done by properties.

# application.properties example showing default values

db-scheduler-log.enabled=true
db-scheduler-log.table-name=scheduled_execution_logs