JobRunr Pro

CI / CD & Job Migrations

Easier continuous delivery thanks to job migrations

Prevent JobNotFoundExceptions thanks to the JobRegressionGuard

Are you applying some of Uncle Bob’s tips and tricks from his great book Clean Code? It probably also means you’re sometimes refactoring… but what about your existing jobs in production? Won’t they break? Will you know if they break?

JobRunr Pro has you covered thanks to the JobRegressionGuard:

@Test
void validateExistingJobs() {
    JobRegressionGuard jobRegressionGuard = new JobRegressionGuard();
    jobRegressionGuard.validateJobs("<url to your staging/production dashboard>");
}
This simple unit test will notify you if you did some refactorings that are not compatible with the jobs in production.

Migrate your jobs with ease

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. Of 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.

Note that the above example is just using a fraction of the API - the actual API to update jobs is much more extensive.