Awesome
db-scheduler-log
Getting started
- Add maven dependency
<dependency>
<groupId>io.rocketbase.extension</groupId>
<artifactId>db-scheduler-log</artifactId>
<version>${version}</version>
</dependency>
- 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.
- 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
- An existing Spring Boot application
- A working
DataSource
with schema initialized. (In the example HSQLDB is used and schema is automatically applied.)
Getting started
- Add the following Maven dependency
NOTE: This includes the db-scheduler-spring-boot-starter dependency itself.<dependency> <groupId>io.rocketbase.extension</groupId> <artifactId>db-scheduler-log-spring-boot-starter</artifactId> <version>${version}</version> </dependency>
- 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