Class RouteDefinition

All Implemented Interfaces:
org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, OutputNode, PreconditionContainer, org.apache.camel.NamedNode, org.apache.camel.NamedRoute, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware, org.apache.camel.spi.ResourceAware

@Metadata(label="configuration") public class RouteDefinition extends OutputDefinition<RouteDefinition> implements org.apache.camel.NamedRoute, PreconditionContainer, org.apache.camel.spi.ResourceAware
A Camel route
  • Constructor Details

    • RouteDefinition

      public RouteDefinition()
    • RouteDefinition

      public RouteDefinition(@AsEndpointUri String uri)
    • RouteDefinition

      public RouteDefinition(org.apache.camel.Endpoint endpoint)
  • Method Details

    • fromRest

      public void fromRest(@AsEndpointUri String uri)
      This route is created from the REST DSL.
    • isPrepared

      public boolean isPrepared()
      Check if the route has been prepared
      Returns:
      whether the route has been prepared or not
      See Also:
    • markPrepared

      public void markPrepared()
      Marks the route definition as prepared.

      This is needed if routes have been created by components such as camel-spring-xml or camel-blueprint. Usually they share logic in the camel-core-xml module which prepares the routes.

    • markUnprepared

      public void markUnprepared()
      Marks the route definition as un-prepared.
    • resetPrepare

      public void resetPrepare()
      Reset internal state before preparing route
    • toString

      public String toString()
      Overrides:
      toString in class OutputDefinition<RouteDefinition>
    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface org.apache.camel.NamedNode
      Overrides:
      getShortName in class OutputDefinition<RouteDefinition>
    • 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<RouteDefinition>
    • getRouteId

      public String getRouteId()
      Specified by:
      getRouteId in interface org.apache.camel.NamedRoute
    • getEndpointUrl

      public String getEndpointUrl()
      Specified by:
      getEndpointUrl in interface org.apache.camel.NamedRoute
    • from

      public RouteDefinition from(@AsEndpointUri String uri)
      Creates an input to the route
      Parameters:
      uri - the from uri
      Returns:
      the builder
    • from

      public RouteDefinition from(org.apache.camel.Endpoint endpoint)
      Creates an input to the route
      Parameters:
      endpoint - the from endpoint
      Returns:
      the builder
    • from

      public RouteDefinition from(EndpointConsumerBuilder endpoint)
      Creates an input to the route
      Parameters:
      endpoint - the from endpoint
      Returns:
      the builder
    • fromV

      public RouteDefinition fromV(@AsEndpointUri String uri, String variableReceive)
      Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers). This is handy for easy access to the received message body via variables.
      Parameters:
      uri - the from uri
      variableReceive - the name of the variable
      Returns:
      the builder
    • fromV

      public RouteDefinition fromV(EndpointConsumerBuilder endpoint, String variableReceive)
      Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers). This is handy for easy access to the received message body via variables.
      Parameters:
      endpoint - the from endpoint
      variableReceive - the name of the variable
      Returns:
      the builder
    • routeConfigurationId

      public RouteDefinition routeConfigurationId(String routeConfigurationId)
      The route configuration id or pattern this route should use for configuration. Multiple id/pattern can be separated by comma.
      Parameters:
      routeConfigurationId - id or pattern
      Returns:
      the builder
    • group

      public RouteDefinition group(String name)
      Set the group name for this route
      Parameters:
      name - the group name
      Returns:
      the builder
    • routeGroup

      public RouteDefinition routeGroup(String group)
      Set the route group for this route
      Overrides:
      routeGroup in class ProcessorDefinition<RouteDefinition>
      Parameters:
      group - the route group
      Returns:
      the builder
    • routeId

      public RouteDefinition routeId(String id)
      Set the route id for this route
      Overrides:
      routeId in class ProcessorDefinition<RouteDefinition>
      Parameters:
      id - the route id
      Returns:
      the builder
    • routeDescription

      public RouteDefinition routeDescription(String description)
      Set the route description for this route
      Overrides:
      routeDescription in class ProcessorDefinition<RouteDefinition>
      Parameters:
      description - the route description
      Returns:
      the builder
    • nodePrefixId

      public RouteDefinition nodePrefixId(String prefixId)
      Sets a prefix to use for all node ids (not route id).
      Overrides:
      nodePrefixId in class ProcessorDefinition<RouteDefinition>
      Parameters:
      prefixId - the prefix
      Returns:
      the builder
    • noStreamCaching

      public RouteDefinition noStreamCaching()
      Disable stream caching for this route.
      Returns:
      the builder
    • streamCaching

      public RouteDefinition streamCaching()
      Enable stream caching for this route.
      Returns:
      the builder
    • streamCaching

      public RouteDefinition streamCaching(String streamCache)
      Enable stream caching for this route.
      Parameters:
      streamCache - whether to use stream caching (true or false), the value can be a property placeholder
      Returns:
      the builder
    • noTracing

      public RouteDefinition noTracing()
      Disable tracing for this route.
      Returns:
      the builder
    • tracing

      public RouteDefinition tracing()
      Enable tracing for this route.
      Returns:
      the builder
    • tracing

      public RouteDefinition tracing(String tracing)
      Enable tracing for this route.
      Parameters:
      tracing - whether to use tracing (true or false), the value can be a property placeholder
      Returns:
      the builder
    • messageHistory

      public RouteDefinition messageHistory()
      Enable message history for this route.
      Returns:
      the builder
    • messageHistory

      public RouteDefinition messageHistory(String messageHistory)
      Enable message history for this route.
      Parameters:
      messageHistory - whether to use message history (true or false), the value can be a property placeholder
      Returns:
      the builder
    • logMask

      public RouteDefinition logMask()
      Enable security mask for Logging on this route.
      Returns:
      the builder
    • logMask

      public RouteDefinition logMask(String logMask)
      Sets whether security mask for logging is enabled on this route.
      Parameters:
      logMask - whether to enable security mask for Logging (true or false), the value can be a property placeholder
      Returns:
      the builder
    • noMessageHistory

      public RouteDefinition noMessageHistory()
      Disable message history for this route.
      Returns:
      the builder
    • noDelayer

      public RouteDefinition noDelayer()
      Disable delayer for this route.
      Returns:
      the builder
    • delayer

      public RouteDefinition delayer(long delay)
      Enable delayer for this route.
      Parameters:
      delay - delay in millis
      Returns:
      the builder
    • errorHandler

      public RouteDefinition errorHandler(String ref)
      Installs the given error handler builder.
      Parameters:
      ref - reference to existing error handler
      Returns:
      the current builder with the error handler configured
    • errorHandler

      public RouteDefinition errorHandler(org.apache.camel.ErrorHandlerFactory errorHandlerBuilder)
      Installs the given error handler builder.
      Parameters:
      errorHandlerBuilder - the error handler to be used by default for all child routes
      Returns:
      the current builder with the error handler configured
    • noAutoStartup

      public RouteDefinition noAutoStartup()
      Disables this route from being auto started when Camel starts.
      Returns:
      the builder
    • autoStartup

      public RouteDefinition autoStartup(String autoStartup)
      Sets the auto startup property on this route.
      Parameters:
      autoStartup - whether to auto startup (true or false), the value can be a property placeholder
      Returns:
      the builder
    • autoStartup

      public RouteDefinition autoStartup(boolean autoStartup)
      Sets the auto startup property on this route.
      Parameters:
      autoStartup - - boolean indicator
      Returns:
      the builder
    • precondition

      public RouteDefinition precondition(String precondition)
      Sets the predicate of the precondition in simple language to evaluate in order to determine if this route should be included or not.
      Parameters:
      precondition - the predicate corresponding to the test to evaluate.
      Returns:
      the builder
    • startupOrder

      public RouteDefinition startupOrder(int order)
      Configures the startup order for this route

      Camel will reorder routes and star them ordered by 0..N where 0 is the lowest number and N the highest number. Camel will stop routes in reverse order when its stopping.

      Overrides:
      startupOrder in class ProcessorDefinition<RouteDefinition>
      Parameters:
      order - the order represented as a number
      Returns:
      the builder
    • routePolicy

      public RouteDefinition routePolicy(org.apache.camel.spi.RoutePolicy... policies)
      Configures route policies for this route
      Parameters:
      policies - the route policies
      Returns:
      the builder
    • routePolicy

      public RouteDefinition routePolicy(Supplier<org.apache.camel.spi.RoutePolicy> policy)
      Configures route policy for this route
      Parameters:
      policy - route policy
      Returns:
      the builder
    • routePolicyRef

      public RouteDefinition routePolicyRef(String routePolicyRef)
      Configures a route policy for this route
      Parameters:
      routePolicyRef - reference to a RoutePolicy to lookup and use. You can specify multiple references by separating using comma.
      Returns:
      the builder
    • shutdownRoute

      public RouteDefinition shutdownRoute(org.apache.camel.ShutdownRoute shutdownRoute)
      Configures a shutdown route option.
      Parameters:
      shutdownRoute - the option to use when shutting down this route
      Returns:
      the builder
    • shutdownRoute

      public RouteDefinition shutdownRoute(String shutdownRoute)
      Configures a shutdown route option.
      Parameters:
      shutdownRoute - the option to use when shutting down this route
      Returns:
      the builder
    • shutdownRunningTask

      public RouteDefinition shutdownRunningTask(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
      Configures a shutdown running task option.
      Parameters:
      shutdownRunningTask - the option to use when shutting down and how to act upon running tasks.
      Returns:
      the builder
    • shutdownRunningTask

      public RouteDefinition shutdownRunningTask(String shutdownRunningTask)
      Configures a shutdown running task option.
      Parameters:
      shutdownRunningTask - the option to use when shutting down and how to act upon running tasks.
      Returns:
      the builder
    • inputType

      public RouteDefinition inputType(String urn)
      Declare the expected data type of the input message. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example java:java.lang.String, json:ABCOrder.
      Parameters:
      urn - input type URN
      Returns:
      the builder
      See Also:
      • Transformer
    • inputTypeWithValidate

      public RouteDefinition inputTypeWithValidate(String urn)
      Declare the expected data type of the input message with content validation enabled. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists, and then applies Validator as well. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example java:java.lang.String, json:ABCOrder.
      Parameters:
      urn - input type URN
      Returns:
      the builder
      See Also:
      • Transformer
      • Validator
    • inputType

      public RouteDefinition inputType(Class<?> clazz)
      Declare the expected data type of the input message by Java class. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists.
      Parameters:
      clazz - Class object of the input type
      Returns:
      the builder
      See Also:
      • Transformer
    • inputTypeWithValidate

      public RouteDefinition inputTypeWithValidate(Class<?> clazz)
      Declare the expected data type of the input message by Java class with content validation enabled. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists, and then applies Validator as well.
      Parameters:
      clazz - Class object of the input type
      Returns:
      the builder
      See Also:
      • Transformer
      • Validator
    • outputType

      public RouteDefinition outputType(String urn)
      Declare the expected data type of the output message. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example java:java.lang.String, json:ABCOrder.
      Parameters:
      urn - output type URN
      Returns:
      the builder
      See Also:
      • Transformer
    • outputTypeWithValidate

      public RouteDefinition outputTypeWithValidate(String urn)
      Declare the expected data type of the output message with content validation enabled. If the actual message type is different at runtime, Camel look for a required Transformer and apply if exists, and then applies Validator as well. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example java:java.lang.String, json:ABCOrder.
      Parameters:
      urn - output type URN
      Returns:
      the builder
      See Also:
      • Transformer
      • Validator
    • outputType

      public RouteDefinition outputType(Class<?> clazz)
      Declare the expected data type of the output message by Java class. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists.
      Parameters:
      clazz - Class object of the output type
      Returns:
      the builder
      See Also:
      • Transformer
    • outputTypeWithValidate

      public RouteDefinition outputTypeWithValidate(Class<?> clazz)
      Declare the expected data type of the output message by Java class with content validation enabled. If the actual message type is different at runtime, camel look for a required Transformer and apply if exists, and then applies Validator as well.
      Parameters:
      clazz - Class object of the output type
      Returns:
      the builder
      See Also:
      • Transformer
      • Validator
    • routeProperty

      public RouteDefinition routeProperty(String key, String value)
      Adds a custom property on the route.
    • getTemplateParameters

      public Map<String,Object> getTemplateParameters()
    • setTemplateParameters

      public void setTemplateParameters(Map<String,Object> templateParameters)
    • getTemplateDefaultParameters

      public Map<String,Object> getTemplateDefaultParameters()
    • setTemplateDefaultParameters

      public void setTemplateDefaultParameters(Map<String,Object> templateDefaultParameters)
    • getRouteTemplateContext

      public org.apache.camel.RouteTemplateContext getRouteTemplateContext()
    • setRouteTemplateContext

      public void setRouteTemplateContext(org.apache.camel.RouteTemplateContext routeTemplateContext)
    • getResource

      public org.apache.camel.spi.Resource getResource()
      Specified by:
      getResource in interface org.apache.camel.spi.ResourceAware
    • setResource

      public void setResource(org.apache.camel.spi.Resource resource)
      Specified by:
      setResource in interface org.apache.camel.spi.ResourceAware
    • getInput

      public FromDefinition getInput()
      Specified by:
      getInput in interface org.apache.camel.NamedRoute
    • setInput

      public void setInput(FromDefinition input)
      Input to the route.
    • getOutputs

      public List<ProcessorDefinition<?>> getOutputs()
      Overrides:
      getOutputs in class OutputDefinition<RouteDefinition>
    • setOutputs

      public void setOutputs(List<ProcessorDefinition<?>> outputs)
      Outputs are processors that determines how messages are processed by this route.
      Overrides:
      setOutputs in class OutputDefinition<RouteDefinition>
    • getRouteConfigurationId

      public String getRouteConfigurationId()
      The route configuration id or pattern this route should use for configuration. Multiple id/pattern can be separated by comma.
    • setRouteConfigurationId

      public void setRouteConfigurationId(String routeConfigurationId)
      The route configuration id or pattern this route should use for configuration. Multiple id/pattern can be separated by comma.
    • addAppliedRouteConfigurationId

      public void addAppliedRouteConfigurationId(String routeConfigurationId)
      This is used internally by Camel to keep track which route configurations is applied when creating a route from this model. This method is not intended for Camel end users.
    • getAppliedRouteConfigurationIds

      public Set<String> getAppliedRouteConfigurationIds()
      This is used internally by Camel to keep track which route configurations is applied when creating a route from this model. This method is not intended for Camel end users.
    • getGroup

      public String getGroup()
      The group that this route belongs to; could be the name of the RouteBuilder class or be explicitly configured in the XML.

      May be null.

    • setGroup

      @Metadata(label="advanced") public void setGroup(String group)
      The group that this route belongs to; could be the name of the RouteBuilder class or be explicitly configured in the XML.

      May be null.

    • getNodePrefixId

      public String getNodePrefixId()
      Prefix to use for all node ids (not route id).
      Specified by:
      getNodePrefixId in interface org.apache.camel.NamedNode
      Specified by:
      getNodePrefixId in interface org.apache.camel.NamedRoute
      Overrides:
      getNodePrefixId in class OptionalIdentifiedDefinition<RouteDefinition>
    • setNodePrefixId

      @Metadata(label="advanced") public void setNodePrefixId(String nodePrefixId)
      Sets a prefix to use for all node ids (not route id).
    • getStreamCache

      public String getStreamCache()
      Whether stream caching is enabled on this route.
    • setStreamCache

      @Metadata(javaType="java.lang.Boolean") public void setStreamCache(String streamCache)
      Whether stream caching is enabled on this route.
    • getTrace

      public String getTrace()
      Whether tracing is enabled on this route.
    • setTrace

      @Metadata(javaType="java.lang.Boolean") public void setTrace(String trace)
      Whether tracing is enabled on this route.
    • getMessageHistory

      public String getMessageHistory()
      Whether message history is enabled on this route.
    • setMessageHistory

      @Metadata(label="advanced", javaType="java.lang.Boolean") public void setMessageHistory(String messageHistory)
      Whether message history is enabled on this route.
    • getLogMask

      public String getLogMask()
      Whether security mask for Logging is enabled on this route.
    • setLogMask

      @Metadata(label="advanced", javaType="java.lang.Boolean") public void setLogMask(String logMask)
      Whether security mask for Logging is enabled on this route.
    • getDelayer

      public String getDelayer()
      Whether to slow down processing messages by a given delay in msec.
    • setDelayer

      @Metadata(label="advanced", javaType="java.lang.Long") public void setDelayer(String delayer)
      Whether to slow down processing messages by a given delay in msec.
    • getAutoStartup

      public String getAutoStartup()
      Whether to auto start this route
    • setAutoStartup

      @Metadata(javaType="java.lang.Boolean", defaultValue="true") public void setAutoStartup(String autoStartup)
      Whether to auto start this route
    • getPrecondition

      public String getPrecondition()
      The predicate of the precondition in simple language to evaluate in order to determine if this route should be included or not.
      Specified by:
      getPrecondition in interface PreconditionContainer
    • setPrecondition

      @Metadata(label="advanced") public void setPrecondition(String precondition)
      The predicate of the precondition in simple language to evaluate in order to determine if this route should be included or not.
      Specified by:
      setPrecondition in interface PreconditionContainer
    • getStartupOrder

      public Integer getStartupOrder()
      To configure the ordering of the routes being started
    • setStartupOrder

      @Metadata(label="advanced", javaType="java.lang.Integer") public void setStartupOrder(Integer startupOrder)
      To configure the ordering of the routes being started
    • setErrorHandlerRef

      public void setErrorHandlerRef(String errorHandlerRef)
      Sets the bean ref name of the error handler builder to use on this route
    • getErrorHandlerRef

      public String getErrorHandlerRef()
      Sets the bean ref name of the error handler builder to use on this route
    • setErrorHandlerFactoryIfNull

      public void setErrorHandlerFactoryIfNull(org.apache.camel.ErrorHandlerFactory errorHandlerFactory)
      Sets the error handler if one is not already set
    • setRoutePolicyRef

      public void setRoutePolicyRef(String routePolicyRef)
      Reference to custom RoutePolicy to use by the route. Multiple policies can be configured by separating values using comma.
    • getRoutePolicyRef

      public String getRoutePolicyRef()
      Reference to custom RoutePolicy to use by the route. Multiple policies can be configured by separating values using comma.
    • getRoutePolicies

      public List<org.apache.camel.spi.RoutePolicy> getRoutePolicies()
    • setRoutePolicies

      public void setRoutePolicies(List<org.apache.camel.spi.RoutePolicy> routePolicies)
    • getShutdownRoute

      public String getShutdownRoute()
    • setShutdownRoute

      @Metadata(label="advanced", javaType="org.apache.camel.ShutdownRoute", defaultValue="Default", enums="Default,Defer") public void setShutdownRoute(String shutdownRoute)
      To control how to shutdown the route.
    • getShutdownRunningTask

      public String getShutdownRunningTask()
      To control how to shut down the route.
    • setShutdownRunningTask

      @Metadata(label="advanced", javaType="org.apache.camel.ShutdownRunningTask", defaultValue="CompleteCurrentTaskOnly", enums="CompleteCurrentTaskOnly,CompleteAllTasks") public void setShutdownRunningTask(String shutdownRunningTask)
      To control how to shut down the route.
    • getErrorHandlerFactory

      public org.apache.camel.ErrorHandlerFactory getErrorHandlerFactory()
    • isErrorHandlerFactorySet

      public boolean isErrorHandlerFactorySet()
      Is a custom error handler been set
    • setErrorHandlerFactory

      public void setErrorHandlerFactory(org.apache.camel.ErrorHandlerFactory errorHandlerFactory)
      Sets the error handler to use with processors created by this builder
    • setRest

      public void setRest(Boolean rest)
      This route is created from REST DSL
    • isRest

      @Metadata(label="advanced") public Boolean isRest()
    • setTemplate

      public void setTemplate(Boolean template)
      This route is created from a route template (or from a Kamelet).
    • isTemplate

      @Metadata(label="advanced") public Boolean isTemplate()
    • setKamelet

      public void setKamelet(Boolean kamelet)
      This route is created from a Kamelet.
    • isKamelet

      @Metadata(label="advanced") public Boolean isKamelet()
    • getRestDefinition

      public RestDefinition getRestDefinition()
    • setRestDefinition

      public void setRestDefinition(RestDefinition restDefinition)
    • getRestBindingDefinition

      public RestBindingDefinition getRestBindingDefinition()
    • setRestBindingDefinition

      public void setRestBindingDefinition(RestBindingDefinition restBindingDefinition)
    • isContextScopedErrorHandler

      public boolean isContextScopedErrorHandler()
    • setInputType

      @Metadata(label="advanced") public void setInputType(InputTypeDefinition inputType)
    • getInputType

      public InputTypeDefinition getInputType()
    • setOutputType

      @Metadata(label="advanced") public void setOutputType(OutputTypeDefinition outputType)
    • getOutputType

      public OutputTypeDefinition getOutputType()
    • getRouteProperties

      public List<PropertyDefinition> getRouteProperties()
    • setRouteProperties

      @Metadata(label="advanced") public void setRouteProperties(List<PropertyDefinition> routeProperties)
      To set metadata as properties on the route.
    • isCreatedFromTemplate

      public boolean isCreatedFromTemplate()
      Specified by:
      isCreatedFromTemplate in interface org.apache.camel.NamedRoute
    • isCreatedFromRest

      public boolean isCreatedFromRest()
      Specified by:
      isCreatedFromRest in interface org.apache.camel.NamedRoute
    • fromUri

      public static RouteDefinition fromUri(String uri)
    • fromEndpoint

      public static RouteDefinition fromEndpoint(org.apache.camel.Endpoint endpoint)