Class CarrotConfiguration


  • public class CarrotConfiguration
    extends Object
    The main class to configure Carrot
    • Method Detail

      • useJsonMapper

        public CarrotConfiguration useJsonMapper​(JsonMapper jsonMapper)
        The JsonMapper to transform tasks to json in the database
        Parameters:
        jsonMapper - the JsonMapper to use
        Returns:
        the same configuration instance which provides a fluent api
      • useStorageProvider

        public CarrotConfiguration useStorageProvider​(PartitionedStorageProvider storageProvider)
        Allows to set the PartitionedStorageProvider that Carrot will use.
        Parameters:
        storageProvider - the PartitionedStorageProvider to use
        Returns:
        the same configuration instance which provides a fluent api
      • usePartitioner

        public CarrotConfiguration usePartitioner​(Partitioner partitioner)
        Allows to set the Partitioner that Carrot will use. If not configured, the default RandomPartitioner will be used.
        Parameters:
        partitioner - the Partitioner to use
        Returns:
        the same configuration instance with provides a fluent api
      • withTaskFilter

        public CarrotConfiguration withTaskFilter​(TaskFilter... taskFilters)
        Allows setting extra TaskFilters or to provide another implementation of the RetryFilter
        Parameters:
        taskFilters - the taskFilters to use for each task.
        Returns:
        the same configuration instance which provides a fluent api
      • useBackgroundTaskServer

        public CarrotConfiguration useBackgroundTaskServer()
        Provides a default BackgroundTaskServer that is configured using a number of threads depending on the amount of CPU.
        Returns:
        the same configuration instance which provides a fluent api
      • useBackgroundTaskServerIf

        public CarrotConfiguration useBackgroundTaskServerIf​(boolean guard)
        Provides a default BackgroundTaskServer 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 BackgroundTaskServer or not.
        Returns:
        the same configuration instance which provides a fluent api
      • useBackgroundTaskServer

        public CarrotConfiguration useBackgroundTaskServer​(int workerCount)
        Provides a default BackgroundTaskServer 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
      • useBackgroundTaskServerIf

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

        public CarrotConfiguration useBackgroundTaskServerIf​(boolean guard,
                                                             BackgroundTaskServerConfiguration configuration,
                                                             boolean startBackgroundTaskServer)
        Provides a default BackgroundTaskServer if the guard is true and that is configured using the given BackgroundTaskServerConfiguration
        Parameters:
        guard - whether to create a BackgroundTaskServer or not.
        configuration - the configuration for the backgroundTaskServer to use
        startBackgroundTaskServer - whether to start the background task server immediately
        Returns:
        the same configuration instance which provides a fluent api
      • useDashboard

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

        public CarrotConfiguration 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 CarrotConfiguration useDashboard​(int dashboardPort)
        Provides a dashboard on the given port
        Parameters:
        dashboardPort - the port on which to start the CarrotDashboardWebServer
        Returns:
        the same configuration instance which provides a fluent api
      • useDashboardIf

        public CarrotConfiguration 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 CarrotDashboardWebServer
        Returns:
        the same configuration instance which provides a fluent api
      • useJmxExtensions

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

        public CarrotConfiguration useJmxExtensionsIf​(boolean guard)
        Enables JMX Extensions to monitor Carrot 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 CarrotConfiguration useMicroMeter​(CarrotMicroMeterIntegration microMeterIntegration)
        Allows integrating MicroMeter metrics into Carrot
        Parameters:
        microMeterIntegration - the CarrotMicroMeterIntegration
        Returns:
        the same configuration instance which provides a fluent api
      • useTaskDetailsGenerator

        public CarrotConfiguration useTaskDetailsGenerator​(TaskDetailsGenerator taskDetailsGenerator)
        Specifies which TaskDetailsGenerator to use.
        Parameters:
        taskDetailsGenerator - the TaskDetailsGenerator to use.
        Returns:
        the same configuration instance which provides a fluent api