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 and AI.
Secondary goal is to support Poor mans Workflow
use the available skill in skills
- use 2.4.x for Spring 3
- use 4.x.x for Spring 4
- JPA-Powered Persistence - Automatically persists tasks to your database
- Spring Boot Auto-Configuration - Simple setup with @EnableSpringPersistentTasks
- Clustering Support for tasks - Built-in lock management for distributed environments and tasks
- Clustering Support for cron tasks - Support for cron tasks in a cluster - run on just one node
- 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 - MySQL, azure-sql-edge, PostgreSQL, and H2
Use the doc for more advanced examples. 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
Consider using the AI skill -- if you improve it please create a PR.
<dependency>
<groupId>org.sterl.spring</groupId>
<artifactId>spring-persistent-tasks-core</artifactId>
<version>4.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>x.x.x</version>
</dependency>@SpringBootApplication
@EnableSpringPersistentTasks
@EnableSpringPersistentTasksUI
public class ExampleApplication {- quartz
- db-scheduler
- jobrunr



