Chapter 3. Migrating to Apache Camel 3
Chapter 3. Migrating to Apache Camel 3 This guide provides information on migrating from Red Hat Fuse 7 to Camel 3 on Spring Boot. NOTE There are important differences between Fuse 7 and Camel 3 in the components, such as modularization and XML Schema changes. See each component section for details. 3.1. Java versions Camel 3 supports Java 17 and Java 11 but not Java 8. In Java 11 the JAXB modules have been removed from the JDK, therefore you will need to add them as Maven dependencies (if you use JAXB such as when using XML DSL or the camel-jaxb component): <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.3.0.1</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.3.2</version> </dependency> NOTE : The Java Platform, Standard Edition 11 Development Kit (JDK 11) is deprecated in Camel Spring Boot 3.x release version and not supported from the further 4.x release versions. 3.2. Modularization of camel-core In Camel 3.x, camel-core has been split into many JARs as follows: camel-api camel-base camel-caffeine-lrucache camel-cloud camel-core camel-jaxp camel-main camel-management-api camel-management camel-support camel-util camel-util-json Maven users of Apache Camel can keep using the dependency camel-core which has transitive dependencies on all of its modules, except for camel-main , and therefore no migration is needed. 3.3. Modularization of Components In Camel 3.x, some of the camel-core components are moved into individual components. camel-attachments camel-bean camel-browse camel-controlbus camel-dataformat camel-dataset camel-direct camel-directvm camel-file camel-language camel-log camel-mock camel-ref camel-rest camel-saga camel-scheduler camel-seda camel-stub camel-timer camel-validator camel-vm camel-xpath camel-xslt camel-xslt-saxon camel-zip-deflater 3.4. Default Shutdown Strategy Red Hat build of Apache Camel supports a shutdown strategy using org.apache.camel.spi.ShutdownStrategy which is responsible for shutting down routes in a graceful manner. Red Hat build of Apache Camel provides a default strategy in the org.apache.camel.impl.engine.DefaultShutdownStrategy to handle the graceful shutdown of the routes. Note The DefaultShutdownStrategy class has been moved from package org.apache.camel.impl to org.apache.camel.impl.engine in Apache Camel 3.x. When you configure a simple scheduled route policy to stop a route, the route stopping algorithm is automatically integrated with the graceful shutdown procedure. This means that the task waits until the current exchange has finished processing before shutting down the route. You can set a timeout, however, that forces the route to stop after the specified time, irrespective of whether or not the route has finished processing the exchange. During graceful shutdown, If you enable the DEBUG logging level on org.apache.camel.impl.engine.DefaultShutdownStrategy , then it logs the same inflight exchange information. If you do not want to see these logs, you can turn this off by setting the option logInflightExchangesOnTimeout to false. 3.5. Multiple CamelContexts per application not supported Support for multiple CamelContexts has been removed and only one CamelContext per deployment is recommended and supported. The context attribute on the various Camel annotations such as @EndpointInject , @Produce , @Consume etc. has therefore been removed. 3.6. Deprecated APIs and Components All deprecated APIs and components from Camel 2.x have been removed in Camel 3. 3.6.1. Removed components All deprecated components from Camel 2.x are removed in Camel 3.x, including the old camel-http , camel-hdfs , camel-mina , camel-mongodb , camel-netty , camel-netty-http , camel-quartz , camel-restlet and camel-rx components. Removed camel-jibx component. Removed camel-boon dataformat. Removed the camel-linkedin component as the Linkedin API 1.0 is no longer supported . Support for the new 2.0 API is tracked by CAMEL-13813 . The camel-zookeeper has its route policy functionality removed, instead use ZooKeeperClusterService or the camel-zookeeper-master component. The camel-jetty component no longer supports producer (which has been removed), use camel-http component instead. The twitter-streaming component has been removed as it relied on the deprecated Twitter Streaming API and is no longer functional. 3.6.2. Renamed components Following components are renamed in Camel 3.x. The Camel-microprofile-metrics has been renamed to camel-micrometer The test component has been renamed to dataset-test and moved out of camel-core into camel-dataset JAR. The http4 component has been renamed to http , and it's corresponding component package from org.apache.camel.component.http4 to org.apache.camel.component.http . The supported schemes are now only http and https . The hdfs2 component has been renamed to hdfs , and it's corresponding component package from org.apache.camel.component.hdfs2 to org.apache.camel.component.hdfs . The supported scheme is now hdfs . The mina2 component has been renamed to mina , and it's corresponding component package from org.apache.camel.component.mina2 to org.apache.camel.component.mina . The supported scheme is now mina . The mongodb3 component has been renamed to mongodb , and it's corresponding component package from org.apache.camel.component.mongodb3 to org.apache.camel.component.mongodb . The supported scheme is now mongodb . The netty4-http component has been renamed to netty-http , and it's corresponding component package from org.apache.camel.component.netty4.http to org.apache.camel.component.netty.http . The supported scheme is now netty-http . The netty4 component has been renamed to netty , and it's corresponding component package from org.apache.camel.component.netty4 to org.apache.camel.component.netty . The supported scheme is now netty . The quartz2 component has been renamed to quartz , and it's corresponding component package from org.apache.camel.component.quartz2 to org.apache.camel.component.quartz . The supported scheme is now quartz . The rxjava2 component has been renamed to rxjava , and it's corresponding component package from org.apache.camel.component.rxjava2 to org.apache.camel.component.rxjava . Renamed camel-jetty9 to camel-jetty . The supported scheme is now jetty . 3.7. Changes to Camel components 3.7.1. Mock component The mock component has been moved out of camel-core . Because of this a number of methods on its assertion clause builder are removed. 3.7.2. ActiveMQ If you are using the activemq-camel component, then you should migrate to use camel-activemq component, where the component name has changed from org.apache.activemq.camel.component.ActiveMQComponent to org.apache.camel.component.activemq.ActiveMQComponent . 3.7.3. AWS The component camel-aws has been split into multiple components: camel-aws-cw camel-aws-ddb (which contains both ddb and ddbstreams components) camel-aws-ec2 camel-aws-iam camel-aws-kinesis (which contains both kinesis and kinesis-firehose components) camel-aws-kms camel-aws-lambda camel-aws-mq camel-aws-s3 camel-aws-sdb camel-aws-ses camel-aws-sns camel-aws-sqs camel-aws-swf Note It is recommended to add specific dependencies for these components. 3.7.4. Camel CXF The camel-cxf JAR has been divided into SOAP vs REST and Spring and non Spring JARs. It is recommended to choose the specific JAR from the following list when migrating from came-cxf . camel-cxf-soap camel-cxf-spring-soap camel-cxf-rest camel-cxf-spring-rest camel-cxf-transport camel-cxf-spring-transport For example, if you were using CXF for SOAP and with Spring XML, then select camel-cxf-spring-soap and camel-cxf-spring-transport when migrating from camel-cxf . When using Spring Boot, choose from the following starter when you migrate from camel-cxf-starter to SOAP or REST: camel-cxf-soap-starter camel-cxf-rest-starter 3.7.4.1. Camel CXF changed namespaces The camel-cxf XML XSD schemas has also changed namespaces. Table 3.1. Changes to namespaces Old Namespace New Namespace http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/jaxws http://camel.apache.org/schema/cxf/camel-cxf.xsd http://camel.apache.org/schema/cxf/jaxws/camel-cxf.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/jaxrs http://camel.apache.org/schema/cxf/camel-cxf.xsd http://camel.apache.org/schema/cxf/jaxrs/camel-cxf.xsd The camel-cxf SOAP component is moved to a new jaxws sub-package, that is, org.apache.camel.component.cxf is now org.apache.camel.component.cxf.jaws . For example, the CxfComponent class is now located in org.apache.camel.component.cxf.jaxws . 3.7.5. FHIR The camel-fhir component has upgraded it's hapi-fhir dependency to 4.1.0. The default FHIR version has been changed to R4. Therefore, if DSTU3 is desired it has to be explicitly set. 3.7.6. Kafka The camel-kafka component has removed the options bridgeEndpoint and circularTopicDetection as this is no longer needed as the component is acting as bridging would work on Camel 2.x. In other words camel-kafka will send messages to the topic from the endpoint uri. To override this use the KafkaConstants.OVERRIDE_TOPIC header with the new topic. See more details in the camel-kafka component documentation. 3.7.7. Telegram The camel-telegram component has moved the authorization token from uri-path to a query parameter instead, e.g. migrate to 3.7.8. JMX If you run Camel standalone with just camel-core as a dependency, and you want JMX enabled out of the box, then you need to add camel-management as a dependency. For using ManagedCamelContext you now need to get this extension from CamelContext as follows: 3.7.9. XSLT The XSLT component has moved out of camel-core into camel-xslt and camel-xslt-saxon . The component is separated so camel-xslt is for using the JDK XSTL engine (Xalan), and camel-xslt-saxon is when you use Saxon. This means that you should use xslt and xslt-saxon as component name in your Camel endpoint URIs. If you are using XSLT aggregation strategy, then use org.apache.camel.component.xslt.saxon.XsltSaxonAggregationStrategy for Saxon support. And use org.apache.camel.component.xslt.saxon.XsltSaxonBuilder for Saxon support if using xslt builder. Also notice that allowStax is also only supported in camel-xslt-saxon as this is not supported by the JDK XSLT. 3.7.10. XML DSL Migration The XML DSL has been changed slightly. The custom load balancer EIP has changed from <custom> to <customLoadBalancer> The XMLSecurity data format has renamed the attribute keyOrTrustStoreParametersId to keyOrTrustStoreParametersRef in the <secureXML> tag. The <zipFile> data format has been renamed to <zipfile> . 3.8. Migrating Camel Maven Plugins The camel-maven-plugin has been split up into two maven plugins: camel-maven-plugin camel-maven-plugin has the run goal, which is intended for quickly running Camel applications standalone. See https://camel.apache.org/manual/camel-maven-plugin.html for more information. camel-report-maven-plugin The camel-report-maven-plugin has the validate and route-coverage goals which is used for generating reports of your Camel projects such as validating Camel endpoint URIs and route coverage reports, etc. See https://camel.apache.org/manual/camel-report-maven-plugin.html for more information.
<dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.1</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.3.0.1</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.3.2</version> </dependency> 2015-01-12 13:23:23,656 [- ShutdownTask] INFO DefaultShutdownStrategy - There are 1 inflight exchanges: InflightExchange: [exchangeId=ID-test-air-62213-1421065401253-0-3, fromRouteId=route1, routeId=route1, nodeId=delay1, elapsed=2007, duration=2017] context.getShutdownStrategegy().setLogInflightExchangesOnTimeout(false); telegram:bots/myTokenHere telegram:bots?authorizationToken=myTokenHere ManagedCamelContext managed = camelContext.getExtension(ManagedCamelContext.class);