Class JobRunrConfiguration

java.lang.Object
org.jobrunr.configuration.JobRunrConfiguration

public class JobRunrConfiguration extends Object
The main class to configure JobRunr
  • Method Details

    • useJsonMapper

      public JobRunrConfiguration useJsonMapper(JsonMapper jsonMapper)
      The JsonMapper to transform jobs to json in the database
      Parameters:
      jsonMapper - the JsonMapper to use
      Returns:
      the same configuration instance which provides a fluent api
    • useJobActivator

      public JobRunrConfiguration useJobActivator(JobActivator jobActivator)
      The JobActivator is used to resolve jobs from the IoC framework
      Parameters:
      jobActivator - the JobActivator to use
      Returns:
      the same configuration instance which provides a fluent api
    • useStorageProvider

      public JobRunrConfiguration useStorageProvider(StorageProvider storageProvider)
      Allows to set the StorageProvider that JobRunr will use.
      Parameters:
      storageProvider - the StorageProvider to use
      Returns:
      the same configuration instance which provides a fluent api
    • withJobFilter

      public JobRunrConfiguration withJobFilter(JobFilter... jobFilters)
      Allows setting extra JobFilters or to provide another implementation of the RetryFilter
      Parameters:
      jobFilters - the jobFilters to use for each job.
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServer

      public JobRunrConfiguration useBackgroundJobServer()
      Provides a default BackgroundJobServer that is configured using a number of threads depending on the amount of CPU.
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServerIf

      public JobRunrConfiguration useBackgroundJobServerIf(boolean guard)
      Provides a default BackgroundJobServer if the guard is true and that is configured using a number of threads depending on the amount of CPU.
      Parameters:
      guard - whether to start a BackgroundJobServer or not.
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServer

      public JobRunrConfiguration useBackgroundJobServer(int workerCount)
      Provides a default BackgroundJobServer that is configured using a given number of threads.
      Parameters:
      workerCount - the number of worker threads to use
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServerIf

      public JobRunrConfiguration useBackgroundJobServerIf(boolean guard, int workerCount)
      Provides a default BackgroundJobServer if the guard is true and that is configured using a given number of threads.
      Parameters:
      guard - whether to start a BackgroundJobServer or not.
      workerCount - the number of worker threads to use
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServer

      public JobRunrConfiguration useBackgroundJobServer(BackgroundJobServerConfiguration configuration)
      Provides a default BackgroundJobServer that is configured using the given BackgroundJobServerConfiguration
      Parameters:
      configuration - the configuration for the backgroundJobServer to use
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServer

      public JobRunrConfiguration useBackgroundJobServer(BackgroundJobServerConfiguration configuration, boolean startBackgroundJobServer)
      Provides a default BackgroundJobServer that is configured using the given BackgroundJobServerConfiguration
      Parameters:
      configuration - the configuration for the backgroundJobServer to use
      startBackgroundJobServer - whether to start the background job server immediately
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServerIf

      public JobRunrConfiguration useBackgroundJobServerIf(boolean guard, BackgroundJobServerConfiguration configuration)
      Provides a default BackgroundJobServer if the guard is true and that is configured using the given BackgroundJobServerConfiguration
      Parameters:
      guard - whether to start a BackgroundJobServer or not.
      configuration - the configuration for the backgroundJobServer to use
      Returns:
      the same configuration instance which provides a fluent api
    • useBackgroundJobServerIf

      public JobRunrConfiguration useBackgroundJobServerIf(boolean guard, BackgroundJobServerConfiguration configuration, boolean startBackgroundJobServer)
      Provides a default BackgroundJobServer if the guard is true and that is configured using the given BackgroundJobServerConfiguration
      Parameters:
      guard - whether to create a BackgroundJobServer or not.
      configuration - the configuration for the backgroundJobServer to use
      startBackgroundJobServer - whether to start the background job server immediately
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboard

      public JobRunrConfiguration useDashboard()
      Provides a dashboard on port 8000
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboardIf

      public JobRunrConfiguration useDashboardIf(boolean guard)
      Provides a dashboard on port 8000 if the guard is true
      Parameters:
      guard - whether to start a Dashboard or not.
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboard

      public JobRunrConfiguration useDashboard(int dashboardPort)
      Provides a dashboard on the given port
      Parameters:
      dashboardPort - the port on which to start the JobRunrDashboardWebServer
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboardIf

      public JobRunrConfiguration useDashboardIf(boolean guard, int dashboardPort)
      Provides a dashboard on the given port if the guard is true
      Parameters:
      guard - whether to start a Dashboard or not.
      dashboardPort - the port on which to start the JobRunrDashboardWebServer
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboard

      public JobRunrConfiguration useDashboard(JobRunrDashboardWebServerConfiguration configuration)
      Provides a dashboard using the given JobRunrDashboardWebServerConfiguration
      Parameters:
      configuration - the JobRunrDashboardWebServerConfiguration to use
      Returns:
      the same configuration instance which provides a fluent api
    • useDashboardIf

      public JobRunrConfiguration useDashboardIf(boolean guard, JobRunrDashboardWebServerConfiguration configuration)
      Provides a dashboard using the given JobRunrDashboardWebServerConfiguration if the guard is true
      Parameters:
      guard - whether to start a Dashboard or not.
      configuration - the JobRunrDashboardWebServerConfiguration to use
      Returns:
      the same configuration instance which provides a fluent api
    • useJmxExtensions

      public JobRunrConfiguration useJmxExtensions()
      If called, this method will register JMX Extensions to monitor JobRunr via JMX
      Returns:
      the same configuration instance which provides a fluent api
    • useJmxExtensionsIf

      public JobRunrConfiguration useJmxExtensionsIf(boolean guard)
      Enables JMX Extensions to monitor JobRunr via JMX if the guard is true
      Parameters:
      guard - whether to start the JXM Extensions or not.
      Returns:
      the same configuration instance which provides a fluent api
    • useMicroMeter

      public JobRunrConfiguration useMicroMeter(JobRunrMicroMeterIntegration microMeterIntegration)
      Allows integrating MicroMeter metrics into JobRunr
      Parameters:
      microMeterIntegration - the JobRunrMicroMeterIntegration
      Returns:
      the same configuration instance which provides a fluent api
    • useJobDetailsGenerator

      public JobRunrConfiguration useJobDetailsGenerator(JobDetailsGenerator jobDetailsGenerator)
      Specifies which JobDetailsGenerator to use.
      Parameters:
      jobDetailsGenerator - the JobDetailsGenerator to use.
      Returns:
      the same configuration instance which provides a fluent api
    • initialize

      Initializes JobRunr and returns a JobScheduler which can then be used to register in the IoC framework or to enqueue/schedule some Jobs.
      Returns:
      a JobScheduler to enqueue/schedule new jobs