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
- JPA-Powered Persistence - Automatically persists tasks to your database
- Spring Boot Auto-Configuration - Simple setup with @EnableSpringPersistentTasks
- Clustering Support - Built-in lock management for distributed environments
- Type-Safe Tasks - Generic task definitions with state objects
- Retry Mechanisms - Automatic retry policies for failed executions
- Transactional Integration - Works with Spring's transaction management
- Queue Management - Intelligent task queuing and prioritization
- Different DB Supports --
Use for more advanced doc the WIKI. The README contains a shorter how to use.
- spring-boot-devtools: cause java.lang.ClassCastException exceptions during the state serialization - this is a java/spring issue
The framework briefly locks a row or trigger to ensure that each trigger is started only on a single node when a cluster is in use. However, some databases still do not support proper row locking and instead lock the entire table. This is not a critical issue but can slow down task selection in very large clusters.
- mySQL
- Azure SQL Edge (maybe also MSSQL)
- MSSQL, as azure-sql-edge is tested
- mySQL: sequences are not supported
<dependency>
<groupId>org.sterl.spring</groupId>
<artifactId>spring-persistent-tasks-core</artifactId>
<version>1.x.x</version>
</dependency>
@SpringBootApplication
@EnableSpringPersistentTasks
public class ExampleApplication {
@Bean
PersistentTask<Vehicle> task1(VehicleHttpConnector vehicleHttpConnector) {
return v -> vehicleHttpConnector.send(v);
}
@Autowired
PersistentTaskService persistentTaskService;
public void triggerTask1(Vehicle vehicle) {
persistentTaskService.runOrQueue(
TriggerBuilder.newTrigger("task1").state(vehicle).build());
}
Liquibase is supported. Either import all or just the required versions.
<include file="spring-persistent-tasks/db.changelog-master.xml" />
<include file="spring-persistent-tasks/db/pt-changelog-v1.xml" />
<dependency>
<groupId>org.sterl.spring</groupId>
<artifactId>spring-persistent-tasks-ui</artifactId>
<version>1.x.x</version>
</dependency>
@SpringBootApplication
@EnableSpringPersistentTasks
@EnableSpringPersistentTasksUI
public class ExampleApplication {
- quartz
- db-scheduler
- jobrunr