The following changes have been made to the Java API:
- ProducerTemplate
Since Apache Camel 2.0, the
org.apache.camel.ProducerTemplateclass has been refactored so thatsendBodymethods now return void for InOnly messaging. Use one of therequestBodymethods for InOut messaging. See Producer and Consumer Templates in Programming EIP Components for more details.- Exchange
Since Apache Camel 2.0, all specializations of
org.apache.camel.Exchangeare now removed. You should now always use theorg.apache.camel.impl.DefaultExchangetype. After analyzing the how exchanges are used, it was realized that the specialized exchanges were not really necessary and by removing them we can avoid a lot of unnecessary copying and improve throughput.One implication of this change is that
ProducerandConsumertypes no longer use generic type declarations. For example, instead of referring toProducer<DefaultExchange>you can just refer to a plainProducer.Since Apache Camel version 2.10, the
containsSynchronizationmethod has been added to theorg.apache.camel.Exchangeinterface.Since Apache Camel version 2.10, the
isTransactionRedeliveredmethod has been added to theorg.apache.camel.Exchangeinterface.- Exchange
getFault()andsetFault()methods Since Apache Camel 2.0, the
getFault()andsetFault()methods are now removed fromExchange. Faults represent application specific errors and are recognized by some protocols. Consequently, it makes more sense to store a fault as the Out message in an exchange (accessed usinggetOut()andsetOut()). Theorg.apache.camel.Messageinterface now exposes the booleanisFault()andsetFault()methods that are used to identify Out messages that represent faults.Because faults represent persistent errors (as opposed to exceptions, which represent transient errors), Camel does not try (as in previous versions) to recover from them (for example, the error handler does not trigger) unless handling faults as exceptions is explicitly enabled.
- AggregationStrategy
Since Apache Camel 2.0, the following changes have been made to the implementation of
org.apache.camel.processor.aggregate.AggregationStrategy:The
aggregate()method is now invoked on the very first exchange. For this first invocation, theoldExchangeparameter isnull.The payload is now always stored in the In message when you do custom aggregation using this strategy interface.
- Aggregator
Since Apache Camel 2.3, the aggregator has been re-implemented and some options have been replaced. In particular, the algorithms for determining batch completeness have changed significantly, so that the
batchSize,outBatchSize,batchTimeout, andbatchConsumeroptions are no longer supported. To understand the new mechanisms for completeness testing, it is recommended that you read Aggregator in Implementing Enterprise Integration Patterns.- CamelContext
Since Apache Camel version 2.1, the following changes have been made to the
CamelContextclass:The
shouldStartContext()method is replaced by theautoStartup()method.The
getLifecycleStrategy()method has been renamedgetLifecycleStrategies()and now returns ajava.util.List.
Since Apache Camel version 2.5, the following changes have been made to the
CamelContextclass:The
stopRoute()method is now integrated with the graceful shutdown strategy (see Controlling Start-Up and Shutdown of Routes in Implementing Enterprise Integration Patterns). You can revert to the old behavior by specifying an explicit timeout.
Since Apache Camel version 2.10, the
setManagementNamemethod has been removed fromorg.apache.camel.CamelContext.- ManagementNamingStrategy
Since Apache Camel version 2.1, the
org.apache.camel.spi.ManagementNamingStrategyhas had methods renamed and method signatures changed in order to accomodate the JMX features in this release.- PollingConsumerPollStrategy
Since Apache Camel version 2.3, the
begin()method fromorg.apache.camel.spi.PollingConsumerPollStrategyreturns a boolean value, wheretrueindicates that polling can now start, whilefalseindicates that polling should be skipped.- RoutePolicy
Since Apache Camel version 2.3, the
org.apache.camel.spi.RoutePolicyinterface has the new method,onInit().Since Apache Camel version 2.9, the
org.apache.camel.spi.RoutePolicyinterface has the following new methods:onRemove,onStart,onStop,onSuspend, andonResume.- Message
Since Apache Camel version 2.3, the
org.apache.camel.Messageinterface has the new method,removeHeaders().Since Apache Camel version 2.10, the
getBody(type)method and thegetHeader(name, type)method fromorg.apache.camel.Messagenow throwTypeConversionException, if an exception occurs during type conversion.- DefaultComponent and DefaultEndpoint
Since Apache Camel version 2.3, the
getExecutorService()andsetExecutorService()methods have been removed from theorg.apache.camel.impl.DefaultComponentandorg.apache.camel.impl.DefaultEndpointclasses. To create a thread pool, use theExecutorServiceManagerobject that is returned by theCamelContext.getExecutorServiceManager()method.For full details of the new threading model, see Threading Model in Implementing Enterprise Integration Patterns.
If you have developed a custom component and you have implemented an endpoint by inheriting from the
DefaultEndpointclass, it is strongly recommended that you override thedoStart()anddoStop()methods, instead of overriding thestart()andstop()methods. Since Apache Camel version 2.7, the default endpoint implementation ensures that thedoStart()anddoStop()methods are called once and once only.- GenericFile
Since Apache Camel version 2.3, the
org.apache.camel.component.file.GenericFileclass is no longer serializable (does not inherit fromjava.io.Serializable).Since Apache Camel version 2.10, the
isDirectorymethod has been added to theorg.apache.camel.component.file.GenericFileinterface.- RouteDefinition
Since Apache Camel version 2.3, the
adviceWith()method fromorg.apache.camel.model.RouteDefinitiontakes aCamelContextinstance as its first parameter.- toAsync
Since Apache Camel version 2.4, the
toAsync()DSL command has been removed. Asynchronous dispatch is now implemented directly (where appropriate) in specific Apache Camel components and DSL commands.- Policy
Since Apache Camel version 2.4, the
org.apache.camel.spi.Policyinterface has the new method,beforeWrap(). For quick migration of yourPolicyclasses, simply add an empty method implementation.- onException
Since Apache Camel version 2.4, the
retryUntiloption ononExceptionhas been renamed toretryWhile, because this reflects the meaning of the option more accurately (it continues to retry while its argument is true).- Routing Slip
Since Apache Camel version 2.4, you can use either a string or an expression to specify the name of the routing slip header. The Spring DSL has changed, such that the
headerNameattribute is now replaced by theheaderNamechild element. For example, to specify the name of the routing slip header to bemyHeader, use an XML fragment like the following:<route> <from uri="direct:a"/> <routingSlip ignoreInvalidEndpoints="true"> <headerName>myHeader</headerName> </routingSlip> </route>- ProducerTemplate
Since Apache Camel version 2.4, all
sendBodyandrequestBodymethods from theProducerTemplateclass throw aCamelExecutionException, which wraps the original exception.- RouteBuilder
Since Apache Camel version 2.4, the
simpleandxpathexpression builder methods are built into theRouteBuilderclass. It is, therefore, no longer necessary to use static imports to access these languages. In your existing code, the Java compiler might complain, if you use static imports forsimpleandxpath. To fix this, just remove the static imports.Since Apache Camel version 2.10, the
errorHandlermethod from theorg.apache.camel.builder.RouteBuilderinterface returnsvoid.- ManagementAware
Since Apache Camel version 2.6, the
org.apache.camel.spi.ManagementAwareinterface is deprecated. If you want to expose a bean through JMX, use the Spring JMX annotations instead.For example, you would annotate a class using the Spring
@ManagedResourceannotation, and then annotate each managed attribute using@ManagedAttributeand each managed operation using@ManagedOperation—see the Spring Reference Guide for details.- DataFormat
Since Apache Camel version 2.6, when implementing a custom data format class, you can also optionally implement the
ServiceandCamelContextAwareinterfaces in order to receive callbacks at initialization and shutdown time. For example, you can implement theMyCustomDataFormatclass with callbacks, as follows:// Java ... public class MyCustomDataFormat implements DataFormat, Service, CamelContextAware { ... }- ScheduledPollConsumer
Since Apache Camel version 2.6, the
pollmethod inScheduledPollConsumernow returns the number of messages actually processed from the poll.- LoggingLevel
Since Apache Camel version 2.7, the
FATALlogging level has been removed fromorg.apache.camel.LoggingLevel. UseERRORinstead.- BinaryPredicate
Since Apache Camel version 2.7, the
getLeftValue()andgetRightValue()methods have been removed fromorg.apache.camel.BinaryPredicate.- PropertiesParser
Since Apache Camel version 2.7, the
parsePropertyValue()method from theorg.apache.camel.component.properties.PropertiesParserinterface has been renamed toparseProperty()and the signature has changed from:// Java // Versions prior to 2.7 String parsePropertyValue(String value);
To the new signature:
// Java // Camel 2.7 or later String parseProperty(String key, String value, Properties properties);
- ManagedCamelContext
Since Apache Camel version 2.7, the
sendBodyandrequestBodymethods from theorg.apache.camel.management.mbean.ManagedCamelContexttake anObjectinstead of aStringas their second parameter. Two new methods,sendStringBodyandrequestStringBody, have been added that take aStringas their second parameter.The new method signatures are as follows:
// NEW method signagures void sendBody(String endpointUri, Object body); Object requestBody(String endpointUri, Object body); void sendStringBody(String endpointUri, String body); Object requestStringBody(String endpointUri, String body);
- errorHandler
Since Apache Camel version 2.8, the deprecated
handledmethods onerrorHandlerhave been removed. If you need the functionality of the handled method (for example, to sethandled(false)), you must migrate to useonException, which still supports thehandledmethod.- InterceptStrategy
Since Apache Camel version 2.8, the semantics of the
wrapProcessorInInterceptorsmethod from theorg.apache.camel.spi.InterceptStrategyclass have changed, so that the actualOutputDefinitioninstance is passed towrapProcessorInInterceptors.- ExecutorServiceStrategy
Since Apache Camel version 2.9, the
org.apache.camel.spi.ExecutorServiceStrategyis deprecated in favor of the newExecutorServiceManagerclass, which has a slightly reduced and improved API. For more details, see Threading Model in Implementing Enterprise Integration Patterns.- ResourceBasedComponent
Since Apache Camel version 2.9, the
org.apache.camel.component.ResourceBasedComponentclass fromcamel-springis deprecated. Useorg.apache.camel.impl.DefaultComponentfromcamel-coreinstead.- ResourceBasedEndpoint
Since Apache Camel version 2.9, the
org.apache.camel.component.ResourceBasedEndpointclass fromcamel-springis deprecated in favor of the neworg.apache.camel.component.ResourceEndpointincamel-core, and its dependency on Spring JARs has been removed. Use the new APIs onResourceEndpointto load resources.- PollingConsumerPollingStrategy
Since Apache Camel version 2.9, the signature of the method,
beforePoll, from theorg.apache.camel.PollingConsumerPollingStrategyclass has changed.- ServiceSupport
Since Apache Camel version 2.9,
ServiceSupportdoes not handle child services any more. The new class,org.apache.camel.support.ChildServiceSupport, now handles this case. Additionally theorg.apache.camel.StatefulServiceinterface has been added, which provides access toServiceSupportmethods without knowing the implementation.- DataFormatResolver
Since Apache Camel version 2.9,
DataFormatResolverdoes not support theresolveDataFormatDefinitionmethod anymore. The current implementations for OSGi and Default were exactly the same, so this code was moved toDefaultCamelContext.- CamelContext
Since Apache Camel version 2.9, all methods in
CamelContextthat reference model elements are deprecated. The new interface,org.apache.camel.model.ModelCamelContext, has been created to hold these methods- FileUtil
Since Apache Camel version 2.9,
renameFilefromorg.apache.camel.util.FileUtilhas a newcopyAndDeleteOnRenameFailboolean option and throwsIOExceptionin case of an exception.- CamelTestSupport
Since Apache Camel version 2.9, the context, template, and consumer fields in
orb.apache.camel.test.CamelTestSupportare no longer static.- WrappedFile
Since Apache Camel version 2.9, the
org.apache.camel.WrappedFileinterface has been introduced, as an abstraction of theGenericFileclass, for use outside the file component.- ScriptBuilder
Since Apache Camel version 2.9, all Spring-related methods in the
org.apache.camel.builder.script.ScriptBuilderclass have been removed (for example, methods takingorg.springframework.core.io.Resourceas an argument).- ErrorHandlerBuilder
Since Apache Camel version 2.9, the
org.apache.camel.builder.ErrorHandlerBuilderinterface'sconfiguremethod takes aorg.apache.camel.spi.RouteContextargument.- ShutdownStrategy
Since Apache Camel version 2.10, the
shutdownForcedandforceShutdownmethods have been added to theorg.apache.camel.spi.ShutdownStrategyinterface.- ShutdownAware
Since Apache Camel version 2.10, the
ShutdownAwareinterface inherits from theShutdownPreparedinterface, which defines the additionalprepareShutdownmethod.- SimpleLanguage
Since Apache Camel version 2.10, the
SimpleLanguageconstructor that takes custom start and end tokens has been removed. Use the staticSimpleLanguage.changeFunctionStartTokenmethod and theSimpleLanguage.changeFunctionEndTokenmethod instead.- LifecycleStrategy
Since Apache Camel version 2.10, the
onThreadPoolRemovemethod and theonErrorHandlerRemovemethod have been added to theorg.apache.camel.spi.LifecycleStrategyinterface.- OnExceptionDefinition
Since Apache Camel version 2.10, the
retryWhile(Expression)method has been removed from theorg.apache.camel.model.OnExceptionDefinitioninterface. Use theretryWhile(Predicate)method instead.- TypeConverter
Since Apache Camel version 2.10, the
convertTomethods onorg.apache.camel.TypeConverterthrowTypeConversionException, if an exception occurs during type conversion. NewtryConvertTomethods have been added toTypeConverter, which ignore any exceptions that might occur during conversion.- UnitOfWork
Since Apache Camel version 2.10, the
containsSynchronizationmethod has been added to theorg.apache.camel.spi.UnitOfWorkinterface.- TypeConverterRegistry
Since Apache Camel version 2.10, the
getStatisticsmethod has been added to theorg.apache.camel.spi.TypeConverterRegistryinterface.- GenericFileProcessStrategy
Since Apache Camel version 2.10, the
abortmethod has been added to theorg.apache.camel.component.file.GenericFileProcessStrategyinterface.
The following classes have been removed from the API:
org.apache.camel.processor.CompositeProcessor org.apache.camel.impl.ProducerTemplateProcessor org.apache.camel.impl.NoPolicy org.apache.camel.spi.Provider org.apache.camel.spring.handler.LazyLoadingBeanDefinitionParser org.apache.camel.spring.handler.ScriptDefinitionParser org.apache.camel.spring.remoting.SendBeforeInterceptor org.apache.camel.spring.spi.SpringConverters
Since Apache Camel version 2.8, the following classes have been removed:
org.apache.camel.spi.ScriptEngineResolver
The following classes have moved to a different Java package:
PollingConsumerPollStrategyhas moved fromorg.apache.cameltoorg.apache.camel.spi.PatternBasedPackageScanFilterhas moved fromorg.apache.camel.impl.scantoorg.apache.camel.spring.
The following classes have been renamed:
org.apache.camel.management.event.ExchangeFailureEventhas been renamed toExchangeFailedEvent.
Since Apache Camel version 2.7, the following classes have been renamed:
org.apache.camel.processor.Loggerhas been renamed toorg.apache.camel.processor.CamelLogger(and now usesslf4jas the logger).
Since Apache Camel version 2.7, the following classes have moved to a different package:
JdbcAggregationRepositoryhas moved fromorg.apache.camel.component.jdbc.aggregationrepositorytoorg.apache.camel.processor.aggregate.jdbc.
Since Apache Camel version 2.8, the following classes have moved to a different package:
GZIPHelperhas moved from the HTTP, HTTP4, and GHttp components to theorg.apache.camel.utilpackage incamel-core.CxfHeaderFilterStrategyhas moved fromorg.apache.camel.component.cxf(incamel-cxf) toorg.apache.camel.component.cxf.common.header(incamel-cxf-transport).ProxyInstantiationExceptionhas moved fromorg.apache.camel.impltoorg.apache.camel.
Since Apache Camel version 2.9, the following classes have moved to a different package:
Orderedhas moved fromorg.apache.camel.utiltoorg.apache.camel.BytesSourceandStringSourcehave moved fromorg.apache.camel.converter.jaxptoorg.apache.camel.TimeoutMaphas moved fromorg.apache.camel.utiltoorg.apache.camel.DefaultTimeoutMaphas moved fromorg.apache.camel.utiltoorg.apache.camel.support.Some management interfaces have moved from
org.apache.camel.managementtoorg.apache.camel.spi.management.DefaultChannelhas moved fromorg.apache.camel.processortoorg.apache.camel.processor.interceptor.ModelHelperhas moved fromorg.apache.camel.utiltoorg.apache.camel.model.ServiceSupporthas moved fromorg.apache.camel.impltoorg.apache.camel.support(the old class is kept, but is deprecated).EventNotifierSupporthas moved fromorg.apache.came.managementtoorg.apache.camel.support(the old class is kept, but is deprecated).








