Skip to content

A simple task management framework like db-scheduler or quartz, but build with spring for spring boot.

License

Notifications You must be signed in to change notification settings

sterlp/spring-persistent-tasks

Repository files navigation

Java CI with Maven

Spring Persistent Tasks

A simple task management framework designed to queue and execute asynchronous tasks with support for database persistence and a user-friendly interface. It can be used to implement scheduling patterns or outbound patterns.

Focus is the usage with spring boot and JPA.

Secondary goal is to support Poor mans Workflow

Documentation

Use for more advanced doc the WIKI. The README contains a shorter how to use.

DBs for storage

Tested in the pipeline

  • H2
  • azure-sql-edge (MSSQL)
  • PostgreSQL
  • MariaDB

History

Supported in theory

  • MSSQL, as azure-sql-edge is tested

Not supported

  • mySQL: sequences are not supported

JavaDoc

Quickstart

Setup with Maven

<dependency>
    <groupId>org.sterl.spring</groupId>
    <artifactId>spring-persistent-tasks-core</artifactId>
    <version>1.x.x</version>
</dependency>

Setup Spring

@SpringBootApplication
@EnableSpringPersistentTasks
public class ExampleApplication {

Create a Task

@Bean
PersistentTask<Vehicle> task1(VehicleHttpConnector vehicleHttpConnector) {
    return v -> vehicleHttpConnector.send(v);
}

Trigger a task

@Autowired
PersistentTaskService persistentTaskService;

public void triggerTask1(Vehicle vehicle) {
    persistentTaskService.runOrQueue(
        TaskTriggerBuilder.newTrigger("task1").state(vehicle).build());
}

JUnit Tests

Setup DB with Liquibase

Liquibase is supported. Either import all or just the required versions.

Maven

Option 1: Just include the master file

<include file="spring-persistent-tasks/db.changelog-master.xml" />

Option 2: import changesets on by one

<include file="spring-persistent-tasks/db/pt-changelog-v1.xml" />

Setup UI

Maven

<dependency>
    <groupId>org.sterl.spring</groupId>
    <artifactId>spring-persistent-tasks-ui</artifactId>
    <version>1.x.x</version>
</dependency>

Setup Spring

@SpringBootApplication
@EnableSpringPersistentTasks
@EnableSpringPersistentTasksUI
public class ExampleApplication {

Open the UI

Schedulers

Schedulers

Triggers

Triggers

History

History

Alternatives

  • quartz
  • db-scheduler
  • jobrunr