Skip to content

Latest commit

 

History

History

README.md

JobRunr — Kotlin Example

A minimal HTTP server that demonstrates three core JobRunr background job patterns.

The app models a newsletter subscription service:

Endpoint Pattern What happens
POST /subscribe Fire-and-forget Confirmation email sent as soon as a worker is free
POST /confirm Delayed Welcome email scheduled for execution 3 days later
(on startup) Recurring Weekly digest sent every Monday

Requirements

  • Java 25 (JVM toolchain)
  • Gradle (wrapper included)

Project structure

kotlin-app/
├── src/main/kotlin/org/jobrunr/example/
│   ├── Main.kt               # HTTP server entry point + JobRunr setup
│   └── services/
│       └── EmailService.kt   # Simulated email jobs (prints to console)
└── build.gradle.kts

Running the app

git clone https://github.com/jobrunr/jobrunr-examples.git
cd jobrunr-examples/kotlin-app
./gradlew run

The server starts on http://localhost:8080 and the JobRunr dashboard on http://localhost:8000/dashboard.

Try it out

# Fire-and-forget: confirmation email sent immediately
curl -X POST "http://localhost:8080/subscribe?email=you@example.com"

# Delayed: welcome email scheduled 3 days from now
curl -X POST "http://localhost:8080/confirm?email=you@example.com"

How it works

See the Getting started with Kotlin guide for a full walkthrough of the code.