org.apache.camel
Interface CamelContext

All Superinterfaces:
RuntimeConfiguration, Service, SuspendableService
All Known Subinterfaces:
ModelCamelContext
All Known Implementing Classes:
DefaultCamelContext

public interface CamelContext
extends SuspendableService, RuntimeConfiguration

Interface used to represent the context used to configure routes and the policies to use during message exchanges between endpoints.

The context offers the following methods to control the lifecycle:

Notice: Service.stop() and SuspendableService.suspend() will gracefully stop/suspend routes ensuring any messages in progress will be given time to complete. See more details at ShutdownStrategy.

If you are doing a hot restart then it's advised to use the suspend/resume methods which ensure a faster restart but also allows any internal state to be kept as is. The stop/start approach will do a cold restart of Camel, where all internal state is reset.

End users are advised to use suspend/resume. Using stop is for shutting down Camel and it's not guaranteed that when it's being started again using the start method that Camel will operate consistently.

Version:

Method Summary
 void addComponent(String componentName, Component component)
          Adds a component to the context.
 Endpoint addEndpoint(String uri, Endpoint endpoint)
          Adds the endpoint to the context using the given URI.
 void addInterceptStrategy(InterceptStrategy interceptStrategy)
          Adds the given interceptor strategy
 void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy)
          Adds the given lifecycle strategy to be used.
 void addRegisterEndpointCallback(EndpointStrategy strategy)
          Registers a callback to allow you to do custom logic when an Endpoint is about to be registered to the CamelContext endpoint registry.
 void addRouteDefinition(RouteDefinition routeDefinition)
          Deprecated. use ModelCamelContext.addRouteDefinition(org.apache.camel.model.RouteDefinition)
 void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
          Deprecated. use ModelCamelContext.addRouteDefinitions(java.util.Collection)
 void addRoutes(RoutesBuilder builder)
          Adds a collection of routes to this context using the given builder to build them.
 void addService(Object object)
          Adds a service to this context, which allows this context to control the lifecycle, ensuring the service is stopped when the context stops.
 void addStartupListener(StartupListener listener)
          Adds the given listener to be invoked when CamelContext have just been started.
 ConsumerTemplate createConsumerTemplate()
          Creates a new ConsumerTemplate which is started and therefore ready to use right away.
 ConsumerTemplate createConsumerTemplate(int maximumCacheSize)
          Creates a new ConsumerTemplate which is started and therefore ready to use right away.
 ProducerTemplate createProducerTemplate()
          Creates a new ProducerTemplate which is started and therefore ready to use right away.
 ProducerTemplate createProducerTemplate(int maximumCacheSize)
          Creates a new ProducerTemplate which is started and therefore ready to use right away.
 void disableJMX()
          Disables using JMX as ManagementStrategy.
 ClassLoader getApplicationContextClassLoader()
          Gets the the application context class loader which may be helpful for running camel in other containers
 ClassResolver getClassResolver()
          Returns the class resolver to be used for loading/lookup of classes.
 Component getComponent(String componentName)
          Gets a component from the context by name.
<T extends Component>
T
getComponent(String name, Class<T> componentType)
          Gets a component from the context by name and specifying the expected type of component.
 List<String> getComponentNames()
          Gets a readonly list of names of the components currently registered
 DataFormatResolver getDataFormatResolver()
          Gets the current data format resolver
 Map<String,DataFormatDefinition> getDataFormats()
          Deprecated. use ModelCamelContext.getDataFormats()
 Debugger getDebugger()
          Gets the current Debugger
 FactoryFinder getDefaultFactoryFinder()
          Gets the default FactoryFinder which will be used for the loading the factory class from META-INF
 InterceptStrategy getDefaultTracer()
          Gets the default tracer
 Endpoint getEndpoint(String uri)
          Resolves the given name to an Endpoint of the specified type.
<T extends Endpoint>
T
getEndpoint(String name, Class<T> endpointType)
          Resolves the given name to an Endpoint of the specified type.
 Map<String,Endpoint> getEndpointMap()
          Returns a new Map containing all of the active endpoints with the key of the map being their unique key.
 Collection<Endpoint> getEndpoints()
          Returns the collection of all registered endpoints.
 ErrorHandlerBuilder getErrorHandlerBuilder()
          Deprecated. The return type will be switched to ErrorHandlerFactory in Camel 3.0
 ScheduledExecutorService getErrorHandlerExecutorService()
          Gets the default shared thread pool for error handlers which leverages this for asynchronous redelivery tasks.
 ExecutorServiceManager getExecutorServiceManager()
          Gets the current ExecutorServiceManager
 ExecutorServiceStrategy getExecutorServiceStrategy()
          Deprecated. use getExecutorServiceManager()
 FactoryFinder getFactoryFinder(String path)
          Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path
 InflightRepository getInflightRepository()
          Gets the inflight repository
 Injector getInjector()
          Returns the injector used to instantiate objects by type
 List<InterceptStrategy> getInterceptStrategies()
          Gets the interceptor strategies
 List<String> getLanguageNames()
          Gets a readonly list with the names of the languages currently registered.
 List<LifecycleStrategy> getLifecycleStrategies()
          Returns the lifecycle strategies used to handle lifecycle notifications
 ManagementMBeanAssembler getManagementMBeanAssembler()
          Returns the management mbean assembler
 String getManagementName()
          Gets the name this CamelContext was registered in JMX.
 ManagementStrategy getManagementStrategy()
          Gets the management strategy
 String getName()
          Gets the name (id) of the this context.
 CamelContextNameStrategy getNameStrategy()
          Gets the current name strategy
 NodeIdFactory getNodeIdFactory()
          Gets the node id factory
 PackageScanClassResolver getPackageScanClassResolver()
          Returns the package scanning class resolver
 ProcessorFactory getProcessorFactory()
          Gets the current ProcessorFactory
 ServicePool<Endpoint,Producer> getProducerServicePool()
          Gets the service pool for Producer pooling.
 Map<String,String> getProperties()
          Gets the properties that can be referenced in the camel context
 String getPropertyPrefixToken()
          Returns the configured property placeholder prefix token if and only if the context has property placeholder abilities, otherwise returns null.
 String getPropertySuffixToken()
          Returns the configured property placeholder suffix token if and only if the context has property placeholder abilities, otherwise returns null.
 Registry getRegistry()
          Returns the registry used to lookup components by name and type such as the Spring ApplicationContext, JNDI or the OSGi Service Registry
 Route getRoute(String id)
          Gets the route with the given id
 RouteDefinition getRouteDefinition(String id)
          Deprecated. use ModelCamelContext.getRouteDefinition(String)
 List<RouteDefinition> getRouteDefinitions()
          Deprecated. use ModelCamelContext.getRouteDefinitions()
 List<Route> getRoutes()
          Returns the current routes in this context
 ServiceStatus getRouteStatus(String routeId)
          Returns the current status of the given route
 ShutdownStrategy getShutdownStrategy()
          Gets the current shutdown strategy
 ServiceStatus getStatus()
          Get the status of this context
 TypeConverter getTypeConverter()
          Returns the type converter used to coerce types from one type to another
 TypeConverterRegistry getTypeConverterRegistry()
          Returns the type converter registry where type converters can be added or looked up
 String getUptime()
          Gets the uptime in a human readable format
 UuidGenerator getUuidGenerator()
          Gets the current UuidGenerator
 String getVersion()
          Gets the version of the this context.
 Component hasComponent(String componentName)
          Is the given component already registered?
 Endpoint hasEndpoint(String uri)
          Is the given endpoint already registered?
 boolean hasService(Object object)
          Has the given service already been added to this context?
 Boolean isLazyLoadTypeConverters()
          Whether or not type converters should be loaded lazy
 boolean isStartingRoutes()
          Indicates whether current thread is starting route(s).
 Boolean isUseBreadcrumb()
          Whether or not breadcrumb is enabled.
 Boolean isUseMDCLogging()
          Whether or not MDC logging is being enabled.
 RoutesDefinition loadRoutesDefinition(InputStream is)
          Deprecated. use ModelCamelContext.loadRoutesDefinition(java.io.InputStream)
 Component removeComponent(String componentName)
          Removes a previously added component.
 Collection<Endpoint> removeEndpoints(String pattern)
          Removes all endpoints with the given URI.
 boolean removeRoute(String routeId)
          Removes the given route (the route must be stopped before it can be removed).
 void removeRouteDefinition(RouteDefinition routeDefinition)
          Deprecated. use ModelCamelContext.removeRouteDefinition(org.apache.camel.model.RouteDefinition)
 void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
          Deprecated. use ModelCamelContext.removeRouteDefinitions(java.util.Collection)
 boolean removeService(Object object)
          Removes a service from this context.
 DataFormat resolveDataFormat(String name)
          Resolve a data format given its name
 DataFormatDefinition resolveDataFormatDefinition(String name)
          Deprecated. use ModelCamelContext.resolveDataFormatDefinition(String)
 Language resolveLanguage(String language)
          Resolves a language for creating expressions
 String resolvePropertyPlaceholders(String text)
          Parses the given text and resolve any property placeholders - using {{key}}.
 void resumeRoute(String routeId)
          Resumes the given route if it has been previously suspended

If the route does not support suspension the route will be started instead

 void setApplicationContextClassLoader(ClassLoader classLoader)
          Sets the application context class loader
 void setClassResolver(ClassResolver resolver)
          Sets the class resolver to be use
 void setDataFormatResolver(DataFormatResolver dataFormatResolver)
          Sets a custom data format resolver
 void setDataFormats(Map<String,DataFormatDefinition> dataFormats)
          Deprecated. use ModelCamelContext.setDataFormats(java.util.Map)
 void setDebugger(Debugger debugger)
          Sets a custom Debugger
 void setDefaultTracer(InterceptStrategy tracer)
          Sets a custom tracer to be used as the default tracer.
 void setErrorHandlerBuilder(ErrorHandlerFactory errorHandlerBuilder)
          Sets the default error handler builder which is inherited by the routes
 void setExecutorServiceManager(ExecutorServiceManager executorServiceManager)
          Sets a custom ExecutorServiceManager
 void setFactoryFinderResolver(FactoryFinderResolver resolver)
          Sets the factory finder resolver to use.
 void setInflightRepository(InflightRepository repository)
          Sets a custom inflight repository to use
 void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters)
          Sets whether type converters should be loaded lazy
 void setManagementName(String name)
          Sets the name this CamelContext was registered in JMX.
 void setManagementStrategy(ManagementStrategy strategy)
          Sets the management strategy to use
 void setNameStrategy(CamelContextNameStrategy nameStrategy)
          Sets a custom name strategy
 void setNodeIdFactory(NodeIdFactory factory)
          Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions
 void setPackageScanClassResolver(PackageScanClassResolver resolver)
          Sets the package scanning class resolver to use
 void setProcessorFactory(ProcessorFactory processorFactory)
          Sets a custom ProcessorFactory
 void setProducerServicePool(ServicePool<Endpoint,Producer> servicePool)
          Sets a pluggable service pool to use for Producer pooling.
 void setProperties(Map<String,String> properties)
          Sets the properties that can be referenced in the camel context
 void setShutdownStrategy(ShutdownStrategy shutdownStrategy)
          Sets a custom shutdown strategy
 void setUseBreadcrumb(Boolean useBreadcrumb)
          Set whether breadcrumb is enabled.
 void setUseMDCLogging(Boolean useMDCLogging)
          Set whether MDC is enabled.
 void setUuidGenerator(UuidGenerator uuidGenerator)
          Sets a custom UuidGenerator (should only be set once)
 void shutdownRoute(String routeId)
          Deprecated. use stopRoute(String) and removeRoute(String)
 void shutdownRoute(String routeId, long timeout, TimeUnit timeUnit)
          Deprecated. use stopRoute(String, long, java.util.concurrent.TimeUnit) and removeRoute(String)
 void startRoute(RouteDefinition route)
          Deprecated. use ModelCamelContext.startRoute(org.apache.camel.model.RouteDefinition)
 void startRoute(String routeId)
          Starts the given route if it has been previously stopped
 void stopRoute(RouteDefinition route)
          Deprecated. use ModelCamelContext.stopRoute(org.apache.camel.model.RouteDefinition)
 void stopRoute(String routeId)
          Stops the given route using ShutdownStrategy.
 void stopRoute(String routeId, long timeout, TimeUnit timeUnit)
          Stops the given route using ShutdownStrategy with a specified timeout.
 boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout)
          Stops the given route using ShutdownStrategy with a specified timeout and optional abortAfterTimeout mode.
 void suspendRoute(String routeId)
          Suspends the given route using ShutdownStrategy.
 void suspendRoute(String routeId, long timeout, TimeUnit timeUnit)
          Suspends the given route using ShutdownStrategy with a specified timeout.
 
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
 
Methods inherited from interface org.apache.camel.Service
start, stop
 
Methods inherited from interface org.apache.camel.RuntimeConfiguration
getDelayer, getShutdownRoute, getShutdownRunningTask, isAutoStartup, isHandleFault, isStreamCaching, isTracing, setAutoStartup, setDelayer, setHandleFault, setShutdownRoute, setShutdownRunningTask, setStreamCaching, setTracing
 

Method Detail

getName

String getName()
Gets the name (id) of the this context.

Returns:
the name

getNameStrategy

CamelContextNameStrategy getNameStrategy()
Gets the current name strategy

Returns:
name strategy

setNameStrategy

void setNameStrategy(CamelContextNameStrategy nameStrategy)
Sets a custom name strategy

Parameters:
nameStrategy - name strategy

getManagementName

String getManagementName()
Gets the name this CamelContext was registered in JMX.

The reason that a CamelContext can have a different name in JMX is the fact to remedy for name clash in JMX when having multiple CamelContexts in the same JVM. Camel will automatic reassign and use a free name to avoid failing to start.

Returns:
the management name

setManagementName

void setManagementName(String name)
Sets the name this CamelContext was registered in JMX.

Parameters:
name - the actual name used when registering this CamelContext in JMX

getVersion

String getVersion()
Gets the version of the this context.

Returns:
the version

getStatus

ServiceStatus getStatus()
Get the status of this context

Returns:
the status

getUptime

String getUptime()
Gets the uptime in a human readable format

Returns:
the uptime in days/hours/minutes

addService

void addService(Object object)
                throws Exception
Adds a service to this context, which allows this context to control the lifecycle, ensuring the service is stopped when the context stops.

The service will also have CamelContext injected if its CamelContextAware. The service will also be enlisted in JMX for management (if JMX is enabled). The service will be started, if its not already started.

Parameters:
object - the service
Throws:
Exception - can be thrown when starting the service

removeService

boolean removeService(Object object)
                      throws Exception
Removes a service from this context.

The service is assumed to have been previously added using addService(Object) method. This method will not change the service lifecycle.

Parameters:
object - the service
Returns:
true if the service was removed, false if no service existed
Throws:
Exception - can be thrown if error removing the service

hasService

boolean hasService(Object object)
Has the given service already been added to this context?

Parameters:
object - the service
Returns:
true if already added, false if not.

addStartupListener

void addStartupListener(StartupListener listener)
                        throws Exception
Adds the given listener to be invoked when CamelContext have just been started.

This allows listeners to do any custom work after the routes and other services have been started and are running.

Important: The listener will always be invoked, also if the CamelContext has already been started, see the StartupListener.onCamelContextStarted(CamelContext, boolean) method.

Parameters:
listener - the listener
Throws:
Exception - can be thrown if CamelContext is already started and the listener is invoked and cause an exception to be thrown

addComponent

void addComponent(String componentName,
                  Component component)
Adds a component to the context.

Parameters:
componentName - the name the component is registered as
component - the component

hasComponent

Component hasComponent(String componentName)
Is the given component already registered?

Parameters:
componentName - the name of the component
Returns:
the registered Component or null if not registered

getComponent

Component getComponent(String componentName)
Gets a component from the context by name.

Parameters:
componentName - the name of the component
Returns:
the component

getComponent

<T extends Component> T getComponent(String name,
                                     Class<T> componentType)
Gets a component from the context by name and specifying the expected type of component.

Parameters:
name - the name to lookup
componentType - the expected type
Returns:
the component

getComponentNames

List<String> getComponentNames()
Gets a readonly list of names of the components currently registered

Returns:
a readonly list with the names of the the components

removeComponent

Component removeComponent(String componentName)
Removes a previously added component.

Parameters:
componentName - the component name to remove
Returns:
the previously added component or null if it had not been previously added.

getEndpoint

Endpoint getEndpoint(String uri)
Resolves the given name to an Endpoint of the specified type. If the name has a singleton endpoint registered, then the singleton is returned. Otherwise, a new Endpoint is created and registered.

Parameters:
uri - the URI of the endpoint
Returns:
the endpoint

getEndpoint

<T extends Endpoint> T getEndpoint(String name,
                                   Class<T> endpointType)
Resolves the given name to an Endpoint of the specified type. If the name has a singleton endpoint registered, then the singleton is returned. Otherwise, a new Endpoint is created and registered.

Parameters:
name - the name of the endpoint
endpointType - the expected type
Returns:
the endpoint

getEndpoints

Collection<Endpoint> getEndpoints()
Returns the collection of all registered endpoints.

Returns:
all endpoints

getEndpointMap

Map<String,Endpoint> getEndpointMap()
Returns a new Map containing all of the active endpoints with the key of the map being their unique key.

Returns:
map of active endpoints

hasEndpoint

Endpoint hasEndpoint(String uri)
Is the given endpoint already registered?

Parameters:
uri - the URI of the endpoint
Returns:
the registered endpoint or null if not registered

addEndpoint

Endpoint addEndpoint(String uri,
                     Endpoint endpoint)
                     throws Exception
Adds the endpoint to the context using the given URI.

Parameters:
uri - the URI to be used to resolve this endpoint
endpoint - the endpoint to be added to the context
Returns:
the old endpoint that was previously registered or null if none was registered
Throws:
Exception - if the new endpoint could not be started or the old endpoint could not be stopped

removeEndpoints

Collection<Endpoint> removeEndpoints(String pattern)
                                     throws Exception
Removes all endpoints with the given URI.

Parameters:
pattern - an uri or pattern to match
Returns:
a collection of endpoints removed which could be empty if there are no endpoints found for the given pattern
Throws:
Exception - if at least one endpoint could not be stopped
See Also:
for pattern

addRegisterEndpointCallback

void addRegisterEndpointCallback(EndpointStrategy strategy)
Registers a callback to allow you to do custom logic when an Endpoint is about to be registered to the CamelContext endpoint registry.

When a callback is added it will be executed on the already registered endpoints allowing you to catch-up

Parameters:
strategy - callback to be invoked

getRouteDefinitions

@Deprecated
List<RouteDefinition> getRouteDefinitions()
Deprecated. use ModelCamelContext.getRouteDefinitions()

Returns a list of the current route definitions

Returns:
list of the current route definitions

getRouteDefinition

@Deprecated
RouteDefinition getRouteDefinition(String id)
Deprecated. use ModelCamelContext.getRouteDefinition(String)

Gets the route definition with the given id

Parameters:
id - id of the route
Returns:
the route definition or null if not found

getRoutes

List<Route> getRoutes()
Returns the current routes in this context

Returns:
the current routes

getRoute

Route getRoute(String id)
Gets the route with the given id

Parameters:
id - id of the route
Returns:
the route or null if not found

addRoutes

void addRoutes(RoutesBuilder builder)
               throws Exception
Adds a collection of routes to this context using the given builder to build them.

Important: The added routes will only be started, if CamelContext is already started. You may want to check the state of CamelContext before adding the routes, using the getStatus() method.

Parameters:
builder - the builder which will create the routes and add them to this context
Throws:
Exception - if the routes could not be created for whatever reason

loadRoutesDefinition

@Deprecated
RoutesDefinition loadRoutesDefinition(InputStream is)
                                      throws Exception
Deprecated. use ModelCamelContext.loadRoutesDefinition(java.io.InputStream)

Loads a collection of route definitions from the given InputStream.

Parameters:
is - input stream with the route(s) definition to add
Returns:
the route definitions
Throws:
Exception - if the route definitions could not be loaded for whatever reason

addRouteDefinitions

@Deprecated
void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
                         throws Exception
Deprecated. use ModelCamelContext.addRouteDefinitions(java.util.Collection)

Adds a collection of route definitions to the context

Parameters:
routeDefinitions - the route(s) definition to add
Throws:
Exception - if the route definitions could not be created for whatever reason

addRouteDefinition

@Deprecated
void addRouteDefinition(RouteDefinition routeDefinition)
                        throws Exception
Deprecated. use ModelCamelContext.addRouteDefinition(org.apache.camel.model.RouteDefinition)

Add a route definition to the context

Parameters:
routeDefinition - the route definition to add
Throws:
Exception - if the route definition could not be created for whatever reason

removeRouteDefinitions

@Deprecated
void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
                            throws Exception
Deprecated. use ModelCamelContext.removeRouteDefinitions(java.util.Collection)

Removes a collection of route definitions from the context - stopping any previously running routes if any of them are actively running

Parameters:
routeDefinitions - route(s) definitions to remove
Throws:
Exception - if the route definitions could not be removed for whatever reason

removeRouteDefinition

@Deprecated
void removeRouteDefinition(RouteDefinition routeDefinition)
                           throws Exception
Deprecated. use ModelCamelContext.removeRouteDefinition(org.apache.camel.model.RouteDefinition)

Removes a route definition from the context - stopping any previously running routes if any of them are actively running

Parameters:
routeDefinition - route definition to remove
Throws:
Exception - if the route definition could not be removed for whatever reason

startRoute

@Deprecated
void startRoute(RouteDefinition route)
                throws Exception
Deprecated. use ModelCamelContext.startRoute(org.apache.camel.model.RouteDefinition)

Starts the given route if it has been previously stopped

Parameters:
route - the route to start
Throws:
Exception - is thrown if the route could not be started for whatever reason

startRoute

void startRoute(String routeId)
                throws Exception
Starts the given route if it has been previously stopped

Parameters:
routeId - the route id
Throws:
Exception - is thrown if the route could not be started for whatever reason

stopRoute

@Deprecated
void stopRoute(RouteDefinition route)
               throws Exception
Deprecated. use ModelCamelContext.stopRoute(org.apache.camel.model.RouteDefinition)

Stops the given route.

Parameters:
route - the route to stop
Throws:
Exception - is thrown if the route could not be stopped for whatever reason

stopRoute

void stopRoute(String routeId)
               throws Exception
Stops the given route using ShutdownStrategy.

Parameters:
routeId - the route id
Throws:
Exception - is thrown if the route could not be stopped for whatever reason
See Also:
suspendRoute(String)

stopRoute

void stopRoute(String routeId,
               long timeout,
               TimeUnit timeUnit)
               throws Exception
Stops the given route using ShutdownStrategy with a specified timeout.

Parameters:
routeId - the route id
timeout - timeout
timeUnit - the unit to use
Throws:
Exception - is thrown if the route could not be stopped for whatever reason
See Also:
suspendRoute(String, long, java.util.concurrent.TimeUnit)

stopRoute

boolean stopRoute(String routeId,
                  long timeout,
                  TimeUnit timeUnit,
                  boolean abortAfterTimeout)
                  throws Exception
Stops the given route using ShutdownStrategy with a specified timeout and optional abortAfterTimeout mode.

Parameters:
routeId - the route id
timeout - timeout
timeUnit - the unit to use
abortAfterTimeout - should abort shutdown after timeout
Returns:
true if the route is stopped before the timeout
Throws:
Exception - is thrown if the route could not be stopped for whatever reason
See Also:
suspendRoute(String, long, java.util.concurrent.TimeUnit)

shutdownRoute

@Deprecated
void shutdownRoute(String routeId)
                   throws Exception
Deprecated. use stopRoute(String) and removeRoute(String)

Shutdown and removes the given route using ShutdownStrategy.

Parameters:
routeId - the route id
Throws:
Exception - is thrown if the route could not be shutdown for whatever reason

shutdownRoute

@Deprecated
void shutdownRoute(String routeId,
                              long timeout,
                              TimeUnit timeUnit)
                   throws Exception
Deprecated. use stopRoute(String, long, java.util.concurrent.TimeUnit) and removeRoute(String)

Shutdown and removes the given route using ShutdownStrategy with a specified timeout.

Parameters:
routeId - the route id
timeout - timeout
timeUnit - the unit to use
Throws:
Exception - is thrown if the route could not be shutdown for whatever reason

removeRoute

boolean removeRoute(String routeId)
                    throws Exception
Removes the given route (the route must be stopped before it can be removed).


A route which is removed will be unregistered from JMX, have its services stopped/shutdown and the route definition etc. will also be removed. All the resources related to the route will be stopped and cleared.


End users can use this method to remove unwanted routes or temporary routes which no longer is in demand.

Parameters:
routeId - the route id
Returns:
true if the route was removed, false if the route could not be removed because its not stopped
Throws:
Exception - is thrown if the route could not be shutdown for whatever reason

resumeRoute

void resumeRoute(String routeId)
                 throws Exception
Resumes the given route if it has been previously suspended

If the route does not support suspension the route will be started instead

Parameters:
routeId - the route id
Throws:
Exception - is thrown if the route could not be resumed for whatever reason

suspendRoute

void suspendRoute(String routeId)
                  throws Exception
Suspends the given route using ShutdownStrategy.

Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) otherwise the consumers will be stopped.

By suspending the route services will be kept running (if possible) and therefore its faster to resume the route.

If the route does not support suspension the route will be stopped instead

Parameters:
routeId - the route id
Throws:
Exception - is thrown if the route could not be suspended for whatever reason

suspendRoute

void suspendRoute(String routeId,
                  long timeout,
                  TimeUnit timeUnit)
                  throws Exception
Suspends the given route using ShutdownStrategy with a specified timeout.

Suspending a route is more gently than stopping, as the route consumers will be suspended (if they support) otherwise the consumers will be stopped.

By suspending the route services will be kept running (if possible) and therefore its faster to resume the route.

If the route does not support suspension the route will be stopped instead

Parameters:
routeId - the route id
timeout - timeout
timeUnit - the unit to use
Throws:
Exception - is thrown if the route could not be suspended for whatever reason

getRouteStatus

ServiceStatus getRouteStatus(String routeId)
Returns the current status of the given route

Parameters:
routeId - the route id
Returns:
the status for the route

isStartingRoutes

boolean isStartingRoutes()
Indicates whether current thread is starting route(s).

This can be useful to know by LifecycleStrategy or the likes, in case they need to react differently.

Returns:
true if current thread is starting route(s), or false if not.

getTypeConverter

TypeConverter getTypeConverter()
Returns the type converter used to coerce types from one type to another

Returns:
the converter

getTypeConverterRegistry

TypeConverterRegistry getTypeConverterRegistry()
Returns the type converter registry where type converters can be added or looked up

Returns:
the type converter registry

getRegistry

Registry getRegistry()
Returns the registry used to lookup components by name and type such as the Spring ApplicationContext, JNDI or the OSGi Service Registry

Returns:
the registry

getInjector

Injector getInjector()
Returns the injector used to instantiate objects by type

Returns:
the injector

getManagementMBeanAssembler

ManagementMBeanAssembler getManagementMBeanAssembler()
Returns the management mbean assembler

Returns:
the mbean assembler

getLifecycleStrategies

List<LifecycleStrategy> getLifecycleStrategies()
Returns the lifecycle strategies used to handle lifecycle notifications

Returns:
the lifecycle strategies

addLifecycleStrategy

void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy)
Adds the given lifecycle strategy to be used.

Parameters:
lifecycleStrategy - the strategy

resolveLanguage

Language resolveLanguage(String language)
Resolves a language for creating expressions

Parameters:
language - name of the language
Returns:
the resolved language

resolvePropertyPlaceholders

String resolvePropertyPlaceholders(String text)
                                   throws Exception
Parses the given text and resolve any property placeholders - using {{key}}.

Parameters:
text - the text such as an endpoint uri or the likes
Returns:
the text with resolved property placeholders
Throws:
Exception - is thrown if property placeholders was used and there was an error resolving them

getPropertyPrefixToken

String getPropertyPrefixToken()
Returns the configured property placeholder prefix token if and only if the context has property placeholder abilities, otherwise returns null.

Returns:
the prefix token or null

getPropertySuffixToken

String getPropertySuffixToken()
Returns the configured property placeholder suffix token if and only if the context has property placeholder abilities, otherwise returns null.

Returns:
the suffix token or null

getLanguageNames

List<String> getLanguageNames()
Gets a readonly list with the names of the languages currently registered.

Returns:
a readonly list with the names of the the languages

createProducerTemplate

ProducerTemplate createProducerTemplate()
Creates a new ProducerTemplate which is started and therefore ready to use right away.

See this FAQ before use: Why does Camel use too many threads with ProducerTemplate?

Will use cache size defined in Camel property with key Exchange.MAXIMUM_CACHE_POOL_SIZE. If no key was defined then it will fallback to a default size of 1000. You can also use the ProducerTemplate.setMaximumCacheSize(int) method to use a custom value before starting the template.

Returns:
the template
Throws:
RuntimeCamelException - is thrown if error starting the template

createProducerTemplate

ProducerTemplate createProducerTemplate(int maximumCacheSize)
Creates a new ProducerTemplate which is started and therefore ready to use right away.

See this FAQ before use: Why does Camel use too many threads with ProducerTemplate?

Parameters:
maximumCacheSize - the maximum cache size
Returns:
the template
Throws:
RuntimeCamelException - is thrown if error starting the template

createConsumerTemplate

ConsumerTemplate createConsumerTemplate()
Creates a new ConsumerTemplate which is started and therefore ready to use right away.

See this FAQ before use: Why does Camel use too many threads with ProducerTemplate? as it also applies for ConsumerTemplate.

Will use cache size defined in Camel property with key Exchange.MAXIMUM_CACHE_POOL_SIZE. If no key was defined then it will fallback to a default size of 1000. You can also use the ConsumerTemplate.setMaximumCacheSize(int) method to use a custom value before starting the template.

Returns:
the template
Throws:
RuntimeCamelException - is thrown if error starting the template

createConsumerTemplate

ConsumerTemplate createConsumerTemplate(int maximumCacheSize)
Creates a new ConsumerTemplate which is started and therefore ready to use right away.

See this FAQ before use: Why does Camel use too many threads with ProducerTemplate? as it also applies for ConsumerTemplate.

Parameters:
maximumCacheSize - the maximum cache size
Returns:
the template
Throws:
RuntimeCamelException - is thrown if error starting the template

addInterceptStrategy

void addInterceptStrategy(InterceptStrategy interceptStrategy)
Adds the given interceptor strategy

Parameters:
interceptStrategy - the strategy

getInterceptStrategies

List<InterceptStrategy> getInterceptStrategies()
Gets the interceptor strategies

Returns:
the list of current interceptor strategies

getErrorHandlerBuilder

@Deprecated
ErrorHandlerBuilder getErrorHandlerBuilder()
Deprecated. The return type will be switched to ErrorHandlerFactory in Camel 3.0

Gets the default error handler builder which is inherited by the routes

Returns:
the builder

setErrorHandlerBuilder

void setErrorHandlerBuilder(ErrorHandlerFactory errorHandlerBuilder)
Sets the default error handler builder which is inherited by the routes

Parameters:
errorHandlerBuilder - the builder

getErrorHandlerExecutorService

ScheduledExecutorService getErrorHandlerExecutorService()
Gets the default shared thread pool for error handlers which leverages this for asynchronous redelivery tasks.


setDataFormats

@Deprecated
void setDataFormats(Map<String,DataFormatDefinition> dataFormats)
Deprecated. use ModelCamelContext.setDataFormats(java.util.Map)

Sets the data formats that can be referenced in the routes.

Parameters:
dataFormats - the data formats

getDataFormats

@Deprecated
Map<String,DataFormatDefinition> getDataFormats()
Deprecated. use ModelCamelContext.getDataFormats()

Gets the data formats that can be referenced in the routes.

Returns:
the data formats available

resolveDataFormat

DataFormat resolveDataFormat(String name)
Resolve a data format given its name

Parameters:
name - the data format name or a reference to it in the Registry
Returns:
the resolved data format, or null if not found

resolveDataFormatDefinition

@Deprecated
DataFormatDefinition resolveDataFormatDefinition(String name)
Deprecated. use ModelCamelContext.resolveDataFormatDefinition(String)

Resolve a data format definition given its name

Parameters:
name - the data format definition name or a reference to it in the Registry
Returns:
the resolved data format definition, or null if not found

getDataFormatResolver

DataFormatResolver getDataFormatResolver()
Gets the current data format resolver

Returns:
the resolver

setDataFormatResolver

void setDataFormatResolver(DataFormatResolver dataFormatResolver)
Sets a custom data format resolver

Parameters:
dataFormatResolver - the resolver

setProperties

void setProperties(Map<String,String> properties)
Sets the properties that can be referenced in the camel context

Parameters:
properties - properties

getProperties

Map<String,String> getProperties()
Gets the properties that can be referenced in the camel context

Returns:
the properties

getDefaultFactoryFinder

FactoryFinder getDefaultFactoryFinder()
Gets the default FactoryFinder which will be used for the loading the factory class from META-INF

Returns:
the default factory finder

setFactoryFinderResolver

void setFactoryFinderResolver(FactoryFinderResolver resolver)
Sets the factory finder resolver to use.

Parameters:
resolver - the factory finder resolver

getFactoryFinder

FactoryFinder getFactoryFinder(String path)
                               throws NoFactoryAvailableException
Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path

Parameters:
path - the META-INF path
Returns:
the factory finder
Throws:
NoFactoryAvailableException - is thrown if a factory could not be found

getClassResolver

ClassResolver getClassResolver()
Returns the class resolver to be used for loading/lookup of classes.

Returns:
the resolver

getPackageScanClassResolver

PackageScanClassResolver getPackageScanClassResolver()
Returns the package scanning class resolver

Returns:
the resolver

setClassResolver

void setClassResolver(ClassResolver resolver)
Sets the class resolver to be use

Parameters:
resolver - the resolver

setPackageScanClassResolver

void setPackageScanClassResolver(PackageScanClassResolver resolver)
Sets the package scanning class resolver to use

Parameters:
resolver - the resolver

setProducerServicePool

void setProducerServicePool(ServicePool<Endpoint,Producer> servicePool)
Sets a pluggable service pool to use for Producer pooling.

Parameters:
servicePool - the pool

getProducerServicePool

ServicePool<Endpoint,Producer> getProducerServicePool()
Gets the service pool for Producer pooling.

Returns:
the service pool

setNodeIdFactory

void setNodeIdFactory(NodeIdFactory factory)
Uses a custom node id factory when generating auto assigned ids to the nodes in the route definitions

Parameters:
factory - custom factory to use

getNodeIdFactory

NodeIdFactory getNodeIdFactory()
Gets the node id factory

Returns:
the node id factory

getManagementStrategy

ManagementStrategy getManagementStrategy()
Gets the management strategy

Returns:
the management strategy

setManagementStrategy

void setManagementStrategy(ManagementStrategy strategy)
Sets the management strategy to use

Parameters:
strategy - the management strategy

getDefaultTracer

InterceptStrategy getDefaultTracer()
Gets the default tracer

Returns:
the default tracer

setDefaultTracer

void setDefaultTracer(InterceptStrategy tracer)
Sets a custom tracer to be used as the default tracer.

Note: This must be set before any routes are created, changing the defaultTracer for existing routes is not supported.

Parameters:
tracer - the custom tracer to use as default tracer

disableJMX

void disableJMX()
Disables using JMX as ManagementStrategy.


getInflightRepository

InflightRepository getInflightRepository()
Gets the inflight repository

Returns:
the repository

setInflightRepository

void setInflightRepository(InflightRepository repository)
Sets a custom inflight repository to use

Parameters:
repository - the repository

getApplicationContextClassLoader

ClassLoader getApplicationContextClassLoader()
Gets the the application context class loader which may be helpful for running camel in other containers

Returns:
the application context class loader

setApplicationContextClassLoader

void setApplicationContextClassLoader(ClassLoader classLoader)
Sets the application context class loader

Parameters:
classLoader - the class loader

getShutdownStrategy

ShutdownStrategy getShutdownStrategy()
Gets the current shutdown strategy

Returns:
the strategy

setShutdownStrategy

void setShutdownStrategy(ShutdownStrategy shutdownStrategy)
Sets a custom shutdown strategy

Parameters:
shutdownStrategy - the custom strategy

getExecutorServiceManager

ExecutorServiceManager getExecutorServiceManager()
Gets the current ExecutorServiceManager

Returns:
the manager

getExecutorServiceStrategy

@Deprecated
ExecutorServiceStrategy getExecutorServiceStrategy()
Deprecated. use getExecutorServiceManager()

Gets the current ExecutorServiceStrategy

Returns:
the manager

setExecutorServiceManager

void setExecutorServiceManager(ExecutorServiceManager executorServiceManager)
Sets a custom ExecutorServiceManager

Parameters:
executorServiceManager - the custom manager

getProcessorFactory

ProcessorFactory getProcessorFactory()
Gets the current ProcessorFactory

Returns:
the factory, can be null if no custom factory has been set

setProcessorFactory

void setProcessorFactory(ProcessorFactory processorFactory)
Sets a custom ProcessorFactory

Parameters:
processorFactory - the custom factory

getDebugger

Debugger getDebugger()
Gets the current Debugger

Returns:
the debugger

setDebugger

void setDebugger(Debugger debugger)
Sets a custom Debugger

Parameters:
debugger - the debugger

getUuidGenerator

UuidGenerator getUuidGenerator()
Gets the current UuidGenerator

Returns:
the uuidGenerator

setUuidGenerator

void setUuidGenerator(UuidGenerator uuidGenerator)
Sets a custom UuidGenerator (should only be set once)

Parameters:
uuidGenerator - the UUID Generator

isLazyLoadTypeConverters

Boolean isLazyLoadTypeConverters()
Whether or not type converters should be loaded lazy

Returns:
true to load lazy, false to load on startup

setLazyLoadTypeConverters

void setLazyLoadTypeConverters(Boolean lazyLoadTypeConverters)
Sets whether type converters should be loaded lazy

Parameters:
lazyLoadTypeConverters - true to load lazy, false to load on startup

isUseMDCLogging

Boolean isUseMDCLogging()
Whether or not MDC logging is being enabled.

Returns:
true if MDC logging is enabled

setUseMDCLogging

void setUseMDCLogging(Boolean useMDCLogging)
Set whether MDC is enabled.

Parameters:
useMDCLogging - true to enable MDC logging, false to disable

isUseBreadcrumb

Boolean isUseBreadcrumb()
Whether or not breadcrumb is enabled.

Returns:
true if breadcrumb is enabled

setUseBreadcrumb

void setUseBreadcrumb(Boolean useBreadcrumb)
Set whether breadcrumb is enabled.

Parameters:
useBreadcrumb - true to enable breadcrumb, false to disable


Apache CAMEL