1 Getting Started

JobRunr is a durable background-job system: it stores job details, lets workers execute them after a request returns, retries failures, and provides an operational dashboard. This guide builds a small delivery API in which creating a delivery commits a GORM row, then schedules a JobRunr job that marks that delivery complete.

The sample is verified with Grails 8.0.0-M5, Gradle 9.6.1, Java 21, and JobRunr OSS 8.8.1. Grails 8.0.0-M5 is a milestone release, while JobRunr 8.8.1 is a GA release. Check the current Apache Grails and JobRunr 8.8.1 release before choosing versions for a new production application.

The design deliberately uses JobRunr OSS only. It stores JobRunr tables in a dedicated data source, sends a small delivery ID rather than an entity graph, waits for the delivery transaction to commit before enqueueing, and makes the handler safe to run again.

What you will build

  • A Grails JSON API that creates a Delivery and returns 201 Created.

  • A durable JobRequest queued after the delivery transaction commits.

  • A statically compiled handler that reports progress and marks the delivery successful.

  • Endpoints that demonstrate immediate, delayed, recurring, and retrying jobs.

  • An H2-backed development dashboard and tests that prove routing, storage separation, and live execution.

1.1 What you will need

To complete this guide, you will need:

  • JDK 21. Grails 8 requires Java 21.

  • About 45 minutes.

  • An IDE with Groovy support.

  • The Gradle wrapper included with the sample. It is pinned to Gradle 9.6.1.

The sample uses in-memory H2 databases for application and JobRunr storage. That is suitable for learning and tests only. The production section explains the persistent writer database and schema workflow.

1.2 How to Complete the Guide

You can work through the code in the guide or clone the finished application:

git clone -b grails8 https://github.com/grails-guides/grails-jobrunr.git
cd grails-jobrunr/complete
./gradlew test

initial/ is a plain Grails 8 web application. complete/ adds the JobRunr starter, Jackson, the dedicated data source, an after-commit event listener, JobRequest handlers, HTTP endpoints, and the tests discussed below.

  Get the Code