Middleware

Middleware allows you to modify the environment of a job before it is executed.

The modifications to the environment only applies to the job being executed. It is reset after the job has been executed.

Configuration

builder.middleware(context -> {
    if (context.job().isTask("fibonacci")) {
        context.environment().put("debug", true);
    } else {
        context.environment().put("debug", false);
    }
    logger.info("On before middleware for job: {}", context.job().getId());
});

Last updated

Was this helpful?