github jobrunr/jobrunr v8.0.0-beta.1

latest releases: v8.2.0, v8.1.0, v8.0.2...
pre-release5 months ago

JobRunr v8.0.0-beta.1

Exciting times! We're pleased to announce the first beta of JobRunr v8. If you have any feedback on the changes listed below, please let us know by opening a discussion: https://github.com/jobrunr/jobrunr/discussions. Thanks for taking the time to try out the v8 beta!

Highlighted Features

Ahead of time scheduled recurring jobs

In v7 and lower, JobRunr schedules recurring jobs very close to the moment they need to run (typically a poll interval earlier). In v8, JobRunr schedules the recurring job as soon as the previous run is finished.

Kotlin Serialisation support

JobRunr v8 introduces a new JsonMapper, KotlinxSerializationJsonMapper to improve the Kotlin developer’s experience when using JobRunr.

Usage

Add the below to build.gradle:

plugins {
  kotlin("plugin.serialization") version "2.1.20"
}

dependencies {
  implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
  implementation("org.jobrunr:jobrunr-kotlin-2.1-support:8.0.0-beta.1")
}

You’ll need to programmatically configure the KotlinxSerializationJsonMapper either using JobRunr fluent API (see below) or by replacing the default JsonMapper bean provided by JobRunr’s autoconfiguration.

@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
fun main() {
    val scheduler = JobRunr.configure()
        .useJsonMapper(KotlinxSerializationJsonMapper())
        // ...
        .jobScheduler!!
}

Note: we have not tested versions lower than 1.8.0 of kotlinx-serialization-json. Additionally, KotlinxSerializationJsonMapper may not be able to deserialize items serialized by another JsonMapper.

Thanks to @SIMULATAN for contributing this feature!

@AsyncJob to reduce boilerplate

A call to a method, annotated with @Job from a class annotated with @AsyncJob, will be intercepted by JobRunr. Instead of the method being executed, an enqueued Job will be created and saved for later execution. This works similarly to Spring’s @Async, which executes the method asynchronously.

Limitation: currently only available for Spring applications.

Usage

@Test
public void testAsyncJob() {
    asyncJobTestService.testMethodAsAsyncJob();
    await().atMost(30, TimeUnit.SECONDS).until(() -> storageProvider.countJobs(StateName.SUCCEEDED) == 1);
}

@AsyncJob
public static class AsyncJobTestService {

    @Job(name = "my async spring job")
    public void testMethodAsAsyncJob() {
        LOGGER.info("Running AsyncJobService.testMethodAsAsyncJob in a job");
    }
}

Thanks to @devashishTaneja for contributing this feature!

Improved @Recurring synchronisation

This feature aims to reduce manual intervention by automatically deleting a RecurringJob when JobRunr cannot find the associated method or when the method is no longer annotated with @Recurring.

Label ordering

Labels are kept in the order they are initially introduced.

End of support for Redis and Elasticsearch

Redis and Elasticsearch StorageProviders were deprected in v7 and are removed from JobRunr in v8.

What's Changed

Breaking Changes

  • AbstractJob#setLabels, JobBuilder#withLabels and RecurringJobBuilder#withLabels now expect a List instead of a Set as an argument.
  • Micrometer: job stats metrics have changed name. Before: jobrunr.jobs.[statename] (where statename takes the value varies. After: jobrunr.jobs.by-state.
  • ScheduledState: removal of constructor ScheduledState(Instant scheduledAt, RecurringJob recurringJob) use ScheduledState.fromRecurringJob(Instant scheduledAt, RecurringJob recurringJob) instead.
  • Remove org from JobRunr’s Spring properties
  • End of support for Redis and Elasticsearch StorageProviders
  • JobDashboardProgressBar: method increaseByOne renamed to incrementSucceeded
  • StorageProvider: getRecurringJobsLatestScheduledRun has been removed, use getRecurringJobScheduledInstants instead.

New Contributors

Full Changelog: v7.5.1...v8.0.0-beta.1

Don't miss a new jobrunr release

NewReleases is sending notifications on new releases.