Class ThreadsDefinition

All Implemented Interfaces:
org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, ExecutorServiceAwareDefinition<ThreadsDefinition>, org.apache.camel.NamedNode, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware

@Metadata(label="eip,routing") public class ThreadsDefinition extends NoOutputDefinition<ThreadsDefinition> implements ExecutorServiceAwareDefinition<ThreadsDefinition>
Specifies that all steps after this node are processed asynchronously
  • Constructor Details

    • ThreadsDefinition

      public ThreadsDefinition()
  • Method Details

    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface org.apache.camel.NamedNode
    • getLabel

      public String getLabel()
      Description copied from class: ProcessorDefinition
      Returns a label to describe this node such as the expression if some kind of expression node
      Specified by:
      getLabel in interface org.apache.camel.NamedNode
      Overrides:
      getLabel in class ProcessorDefinition<ThreadsDefinition>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • executorService

      public ThreadsDefinition executorService(ExecutorService executorService)
      To use a custom thread pool
      Specified by:
      executorService in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
      Parameters:
      executorService - the executor service
      Returns:
      the builder
    • executorService

      public ThreadsDefinition executorService(String executorService)
      To refer to a custom thread pool or use a thread pool profile (as overlay)
      Specified by:
      executorService in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
      Parameters:
      executorService - reference for a ExecutorService to lookup in the Registry
      Returns:
      the builder
    • poolSize

      public ThreadsDefinition poolSize(int poolSize)
      Sets the core pool size
      Parameters:
      poolSize - the core pool size to keep minimum in the pool
      Returns:
      the builder
    • poolSize

      public ThreadsDefinition poolSize(String poolSize)
      Sets the core pool size
      Parameters:
      poolSize - the core pool size to keep minimum in the pool
      Returns:
      the builder
    • maxPoolSize

      public ThreadsDefinition maxPoolSize(int maxPoolSize)
      Sets the maximum pool size
      Parameters:
      maxPoolSize - the maximum pool size
      Returns:
      the builder
    • maxPoolSize

      public ThreadsDefinition maxPoolSize(String maxPoolSize)
      Sets the maximum pool size
      Parameters:
      maxPoolSize - the maximum pool size
      Returns:
      the builder
    • keepAliveTime

      public ThreadsDefinition keepAliveTime(long keepAliveTime)
      Sets the keep alive time for idle threads
      Parameters:
      keepAliveTime - keep alive time
      Returns:
      the builder
    • keepAliveTime

      public ThreadsDefinition keepAliveTime(String keepAliveTime)
      Sets the keep alive time for idle threads
      Parameters:
      keepAliveTime - keep alive time
      Returns:
      the builder
    • timeUnit

      public ThreadsDefinition timeUnit(TimeUnit keepAliveTimeUnits)
      Sets the keep alive time unit. By default SECONDS is used.
      Parameters:
      keepAliveTimeUnits - time unit
      Returns:
      the builder
    • timeUnit

      public ThreadsDefinition timeUnit(String keepAliveTimeUnits)
      Sets the keep alive time unit. By default SECONDS is used.
      Parameters:
      keepAliveTimeUnits - time unit
      Returns:
      the builder
    • maxQueueSize

      public ThreadsDefinition maxQueueSize(int maxQueueSize)
      Sets the maximum number of tasks in the work queue.

      Use -1 or Integer.MAX_VALUE for an unbounded queue

      Parameters:
      maxQueueSize - the max queue size
      Returns:
      the builder
    • maxQueueSize

      public ThreadsDefinition maxQueueSize(String maxQueueSize)
      Sets the maximum number of tasks in the work queue.

      Use -1 or Integer.MAX_VALUE for an unbounded queue

      Parameters:
      maxQueueSize - the max queue size
      Returns:
      the builder
    • rejectedPolicy

      public ThreadsDefinition rejectedPolicy(org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy rejectedPolicy)
      Sets the handler for tasks which cannot be executed by the thread pool.
      Parameters:
      rejectedPolicy - the policy for the handler
      Returns:
      the builder
    • rejectedPolicy

      public ThreadsDefinition rejectedPolicy(String rejectedPolicy)
      Sets the handler for tasks which cannot be executed by the thread pool.
      Parameters:
      rejectedPolicy - the policy for the handler
      Returns:
      the builder
    • threadName

      public ThreadsDefinition threadName(String threadName)
      Sets the thread name to use.
      Parameters:
      threadName - the thread name
      Returns:
      the builder
    • callerRunsWhenRejected

      public ThreadsDefinition callerRunsWhenRejected(boolean callerRunsWhenRejected)
      Whether or not to use as caller runs as fallback when a task is rejected being added to the thread pool (when its full). This is only used as fallback if no rejectedPolicy has been configured, or the thread pool has no configured rejection handler.

      Is by default true

      Parameters:
      callerRunsWhenRejected - whether or not the caller should run
      Returns:
      the builder
    • callerRunsWhenRejected

      public ThreadsDefinition callerRunsWhenRejected(String callerRunsWhenRejected)
      Whether or not to use as caller runs as fallback when a task is rejected being added to the thread pool (when its full). This is only used as fallback if no rejectedPolicy has been configured, or the thread pool has no configured rejection handler.

      Is by default true

      Parameters:
      callerRunsWhenRejected - whether or not the caller should run
      Returns:
      the builder
    • allowCoreThreadTimeOut

      public ThreadsDefinition allowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
      Whether idle core threads are allowed to timeout and therefore can shrink the pool size below the core pool size

      Is by default false

      Parameters:
      allowCoreThreadTimeOut - true to allow timeout
      Returns:
      the builder
    • allowCoreThreadTimeOut

      public ThreadsDefinition allowCoreThreadTimeOut(String allowCoreThreadTimeOut)
      Whether idle core threads is allowed to timeout and therefore can shrink the pool size below the core pool size

      Is by default false

      Parameters:
      allowCoreThreadTimeOut - true to allow timeout
      Returns:
      the builder
    • getExecutorServiceBean

      public ExecutorService getExecutorServiceBean()
      Description copied from interface: ExecutorServiceAwareDefinition
      Gets the executor service for executing
      Specified by:
      getExecutorServiceBean in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
    • getExecutorServiceRef

      public String getExecutorServiceRef()
      Description copied from interface: ExecutorServiceAwareDefinition
      Gets a reference id to lookup the executor service from the registry
      Specified by:
      getExecutorServiceRef in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
    • getPoolSize

      public String getPoolSize()
    • setPoolSize

      public void setPoolSize(String poolSize)
    • getMaxPoolSize

      public String getMaxPoolSize()
    • setMaxPoolSize

      public void setMaxPoolSize(String maxPoolSize)
    • getKeepAliveTime

      public String getKeepAliveTime()
    • setKeepAliveTime

      public void setKeepAliveTime(String keepAliveTime)
    • getTimeUnit

      public String getTimeUnit()
    • setTimeUnit

      public void setTimeUnit(String timeUnit)
    • getMaxQueueSize

      public String getMaxQueueSize()
    • setMaxQueueSize

      public void setMaxQueueSize(String maxQueueSize)
    • getThreadName

      public String getThreadName()
    • setThreadName

      public void setThreadName(String threadName)
    • getRejectedPolicy

      public String getRejectedPolicy()
    • setRejectedPolicy

      public void setRejectedPolicy(String rejectedPolicy)
    • getCallerRunsWhenRejected

      public String getCallerRunsWhenRejected()
    • setCallerRunsWhenRejected

      public void setCallerRunsWhenRejected(String callerRunsWhenRejected)
    • getAllowCoreThreadTimeOut

      public String getAllowCoreThreadTimeOut()
    • setAllowCoreThreadTimeOut

      public void setAllowCoreThreadTimeOut(String allowCoreThreadTimeOut)
    • getExecutorService

      public String getExecutorService()
    • setExecutorService

      public void setExecutorService(String executorService)