https://github.com/jobrunr/jobrunr
An extremely easy way to perform background processing in Java. Backed by persistent storage. Open and free for commercial use.
https://github.com/jobrunr/jobrunr
background-jobs java java-8 java-scheduler parallel-processing quartz scheduled-jobs scheduler scheduling
Last synced: 4 months ago
JSON representation
An extremely easy way to perform background processing in Java. Backed by persistent storage. Open and free for commercial use.
- Host: GitHub
- URL: https://github.com/jobrunr/jobrunr
- Owner: jobrunr
- License: other
- Created: 2020-04-02T17:34:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2026-01-14T10:56:28.000Z (5 months ago)
- Last Synced: 2026-01-16T23:34:08.569Z (5 months ago)
- Topics: background-jobs, java, java-8, java-scheduler, parallel-processing, quartz, scheduled-jobs, scheduler, scheduling
- Language: Java
- Homepage: https://www.jobrunr.io/en/
- Size: 12.4 MB
- Stars: 2,834
- Watchers: 31
- Forks: 300
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: License-lgpl.md
- Security: SECURITY.md
- Cla: CLA.md
Awesome Lists containing this project
- awesome-java - JobRunr
- fucking-awesome-java - JobRunr - Job scheduling library which utilizes lambdas for fire-and-forget, delayed and recurring jobs. Guarantees execution by single scheduler instance using optimistic locking. Has features for persistence, minimal dependencies and is embeddable. (Projects / Job Scheduling)
- awesome-java-zh - JobRunr - 作业调度库,它利用lambdas进行fire-and-forget,延迟和重复的作业。使用乐观锁定保证由单个调度程序实例执行。具有持久性,最小依赖性和可嵌入的功能。 (项目 / 作业调度)
- awesome - jobrunr/jobrunr - An extremely easy way to perform background processing in Java. Backed by persistent storage. Open and free for commercial use. (<a name="Java"></a>Java)
- awesome-java - JobRunr - Job scheduling library which utilizes lambdas for fire-and-forget, delayed and recurring jobs. Guarantees execution by single scheduler instance using optimistic locking. Has features for persistence, minimal dependencies and is embeddable. (Projects / Job Scheduling)
README
The ultimate library to perform background processing on the JVM.
Dead simple API. Extensible. Reliable.
Distributed and backed by persistent storage.
Open and free for commercial use.
Recommended and loved by ThoughtWorks.
## Overview
```java
BackgroundJob.enqueue(() -> System.out.println("This is all you need for distributed jobs!"));
```
Incredibly easy way to perform **fire-and-forget**, **delayed**, **scheduled** and **recurring jobs** inside **Java applications** using only *Java 8 lambda's*. CPU and I/O intensive, long-running and short-running jobs are supported. Persistent storage is done via either RDBMS (e.g. Postgres, MariaDB/MySQL, Oracle, SQL Server, DB2 and SQLite) or NoSQL (MongoDB).
JobRunr provides a unified programming model to handle background tasks in a **reliable way** and runs them on shared hosting, dedicated hosting or in the cloud ([hello Kubernetes](https://www.jobrunr.io/en/blog/2020-05-06-jobrunr-kubrnetes-terraform/)) within a JVM instance.
## Feedback
> Thanks for building JobRunr, I like it a lot! Before that I used similar libraries in Ruby and Golang and JobRunr so far is the most pleasant one to use. I especially like the dashboard, it’s awesome! [Alex Denisov](https://www.linkedin.com/in/alex-denisov-a29bab2a/)
View more feedback on [jobrunr.io](https://www.jobrunr.io/en/#why-jobrunr).
## Features
- Simple: just use Java 8 lambda's to create a background job.
- Distributed & cluster-friendly: guarantees execution by single scheduler instance using optimistic locking.
- Persistent jobs: using either a RDBMS (four tables and a view) or a NoSQL data store.
- Embeddable: built to be embedded in existing applications.
- Minimal dependencies: ([ASM](https://asm.ow2.io/), slf4j and either [jackson](https://github.com/FasterXML/jackson) and jackson-datatype-jsr310, [gson](https://github.com/google/gson) or a JSON-B compliant library).
## Usage scenarios
Some scenarios where it may be a good fit:
- within a REST api return response to client immediately and perform long-running job in the background
- mass notifications/newsletters
- calculations of wages and the creation of the resulting documents
- batch import from xml, csv or json
- creation of archives
- firing off web hooks
- image/video processing
- purging temporary files
- recurring automated reports
- database maintenance
- updating elasticsearch/solr after data changes
- *…and so on*
You can start small and process jobs within your web app or scale horizontally and add as many background job servers as you want to handle a peak of jobs. JobRunr will distribute the load over all the servers for you. JobRunr is also fault-tolerant - is an external web service down? No worries, the job is automatically retried 10-times with a smart back-off policy.
JobRunr is a Java alternative to [HangFire](https://github.com/HangfireIO/Hangfire), [Resque](https://github.com/resque/resque), [Sidekiq](http://sidekiq.org), [delayed_job](https://github.com/collectiveidea/delayed_job), [Celery](https://github.com/celery/celery) and is similar to [Quartz](https://github.com/quartz-scheduler/quartz) and [Spring Task Scheduler](https://github.com/spring-guides/gs-scheduling-tasks).
Screenshots
-----------

Usage
------
[**Fire-and-forget tasks**](https://www.jobrunr.io/en/documentation/background-methods/enqueueing-jobs/)
Dedicated worker pool threads execute queued background jobs as soon as possible, shortening your request's processing time.
```java
BackgroundJob.enqueue(() -> System.out.println("Simple!"));
```
[**Delayed tasks**](https://www.jobrunr.io/en/documentation/background-methods/scheduling-jobs/)
Scheduled background jobs are executed only after a given amount of time.
```java
BackgroundJob.schedule(Instant.now().plusHours(5), () -> System.out.println("Reliable!"));
```
[**Recurring tasks**](https://www.jobrunr.io/en/documentation/background-methods/recurring-jobs/)
Recurring jobs have never been simpler; just call the following method to perform any kind of recurring task using the [CRON expressions](http://en.wikipedia.org/wiki/Cron#CRON_expression).
```java
BackgroundJob.scheduleRecurrently("my-recurring-job", Cron.daily(), () -> service.doWork());
```
**Process background tasks inside a web application…**
You can process background tasks in any web application and we have thorough support for [Spring](https://spring.io/) - JobRunr is reliable to process your background jobs within a web application.
**… or anywhere else**
Like a Spring Console Application, wrapped in a docker container, that keeps running forever and polls for new background jobs.
See [https://www.jobrunr.io](https://www.jobrunr.io) for more info.
Installation
------------
#### Using Maven?
JobRunr is available in Maven Central - all you need to do is add the following dependency:
```xml
org.jobrunr
jobrunr
${jobrunr.version}
```
#### Using Gradle?
Just add the dependency to JobRunr:
```groovy
implementation 'org.jobrunr:jobrunr:${jobrunr.version}'
```
Configuration
------------
#### Do you like to work Spring based?
Add the [*jobrunr-spring-boot-3-starter*](https://search.maven.org/artifact/org.jobrunr/jobrunr-spring-boot-3-starter) to your dependencies and you're almost ready to go! Just set up your `application.properties`:
```
# the job-scheduler is enabled by default
# the background-job-server and dashboard are disabled by default
jobrunr.job-scheduler.enabled=true
jobrunr.background-job-server.enabled=true
jobrunr.dashboard.enabled=true
```
#### Or do you prefer a fluent API?
Define a `javax.sql.DataSource` and put the following code on startup:
```java
@SpringBootApplication
public class JobRunrApplication {
public static void main(String[] args) {
SpringApplication.run(JobRunrApplication.class, args);
}
@Bean
public JobScheduler initJobRunr(DataSource dataSource, JobActivator jobActivator) {
return JobRunr.configure()
.useJobActivator(jobActivator)
.useStorageProvider(SqlStorageProviderFactory
.using(dataSource))
.useBackgroundJobServer()
.useDashboard()
.initialize().getJobScheduler();
}
}
```
## Contributing
See [CONTRIBUTING](https://github.com/jobrunr/jobrunr/blob/master/CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
### How can I contribute?
* Take a look at issues with tag called [`Good first issue`](https://github.com/jobrunr/jobrunr/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
* Join the discussion on [Github discussion](https://github.com/jobrunr/jobrunr/discussions) - we won't be using Gitter anymore.
* Answer questions on [issues](https://github.com/jobrunr/jobrunr/issues).
* Fix bugs reported on [issues](https://github.com/jobrunr/jobrunr/issues), and send us pull request.
### How to build?
* `git clone https://github.com/jobrunr/jobrunr.git`
* `cd jobrunr`
* `cd core/src/main/resources/org/jobrunr/dashboard/frontend`
* `npm i`
* `npm run build`
* `cd -`
* `./gradlew publishToMavenLocal`
Then, in your own project you can depend on `org.jobrunr:jobrunr:1.0.0-SNAPSHOT`.
