Job Migrations

Easier continuous delivery thanks to job migrations

Do you have a lot of scheduled jobs planned in the future? And you need to do some refactoring? Just migrate your existing jobs to your new API and continue delivering working jobs with each deploy.

A job migration could not have been easier with the new migrations API.

JobRunrPro
    .configure()
    .useJobNotFoundConfiguration(usingStandardJobNotFoundConfiguration()
            .andMigrateScheduledJobsThatAreNotFound(
                    ((scheduledJobMatcher, scheduledJobUpdater) -> {
                        if (scheduledJobMatcher.matches(TestService.class, "doWorkThatDoesNotExist")) {
                            scheduledJobUpdater.setMethodName("doWork");
                        }
                    }),
                    ((scheduledJobMatcher, scheduledJobUpdater) -> {
                        if (scheduledJobMatcher.matches("i.dont.exist.Class")) {
                            scheduledJobUpdater.deleteJob();
                        }
                    })
    ))

You can easily update jobs that do not exist anymore in your code via the scheduledJobUpdater class. Off-course, you can also add, remove and even update parameters from your old jobs.

These new migrations are also supported via the framework integrations using the ScheduledJobThatDoNotExistAnymoreMigrations bean.

@Singleton
public ScheduledJobThatDoNotExistAnymoreMigrations scheduledJobThatDoNotExistAnymoreMigrations() {
    return new ScheduledJobThatDoNotExistAnymoreMigrations(
        ((scheduledJobMatcher, scheduledJobUpdater) -> {
            if (scheduledJobMatcher.matches(TestService.class, "doWorkThatDoesNotExist")) {
                scheduledJobUpdater.setMethodName("doWork");
            }
        }),
        ((scheduledJobMatcher, scheduledJobUpdater) -> {
            if (scheduledJobMatcher.matches("i.dont.exist.Class")) {
                scheduledJobUpdater.deleteJob();
            }
        })
    );
}

Updating existing jobs is possible in Spring, Micronaut and Quarkus by creating a ScheduledJobThatDoNotExistAnymoreMigrations bean.