This document is for helping you upgrade your Apache Camel application from Camel 4.x to 4.y. For example, if you are upgrading Camel 4.0 to 4.2, then you should follow the guides from both 4.0 to 4.1 and 4.1 to 4.2.
Camel startup summary will now report total number of routes without (internal routes created by Kamelets or Rest DSL). This ensures the total number better reflect the total number of user created routes. The summary now includes a separate number of Kamelets and Rest DSL routes. See also the camel-kamelet section.
The following deprecated methods from the AbstractCamelContext
, deprecated on 4.2 as part of CAMEL-19998, were finally removed:
-
setTypeConverter
-
getOrCreateTypeConverter
-
setManagementMBeanAssembler
-
getRestRegistryFactory
-
setRestRegistryFactory
-
setTransformerRegistry
-
setValidatorRegistry
-
setName
-
setDescription
-
getBootstrapFactoryFinder
-
getFactoryFinder
-
addInterceptStrategy
-
getStartupStepRecorder
-
setStartupStepRecorder
-
resolvePropertyPlaceholders
-
getBasePackageScan
-
setBasePackageScan
Users of these methods should use the respective operations from the ExtendedCamelContext
(accessed via getCamelContextExtension()
),
instead.
The following deprecated methods from the CamelContext
, deprecated on 4.4 as part of CAMEL-20225, were finally removed and/or modified:
-
getUptime
: modified to return a regularDuration
instance. -
getUptimeMillis
: removed. -
getStartDate
removed.
Users of this method should proceed as following:
-
getUptime
: useContextHelper.getUptime
. -
getUptimeMillis
: usegetUptime().toMillis()
. -
getStartDate
: useContextHelper.getStartDate
.
Camel has changed the default value for inlineRoutes=false
to inlineRoutes=true
in restConfiguration
.
It is very typical to define Rest DSL and for each service api, then call a Camel route via direct
endpoints.
By inlining these two, then you only have 1 route in Camel instead of 2. This helps reduce the clutter of routes
that otherwise is in use when using Rest DSL and many services. You can restore to old behaviour by setting the option back to inlineRoutes=false
.
However, the inlining requires that each REST endpoint inlined with direct
endpoints must use unique direct names, ie.
rest("/rest")
.get("/").to("direct:printMethod")
.post("/").to("direct:printMethod")
.put("/").to("direct:printMethod");
Should be changed to:
rest("/rest")
.get("/").to("direct:printMethod1")
.post("/").to("direct:printMethod2")
.put("/").to("direct:printMethod3");
Or to keep old behaviour, you can turn off inlining.
Rest DSL will now eagerly resolve property placeholders that are used during building the rest:
endpoint.
For example with a Rest DSL using a placeholder (app.mypath = helloapp
) in the path
:
- rest:
path: "{{app.mypath}}"
post:
- to: direct:demo
Will not be resolved in the rest
endpoint which can be seen during startup logging:
Routes startup (total:2)
Started demo (rest://post:%7B%7Bapp.mypath%7D%7D)
The placeholder is now resolved eagerly and you will see nicer startup logs such as:
Routes startup (total:2)
Started demo (rest://post:helloapp)
The restConfiguration
has changed default value in the useXForwardHeaders
option from true
to false
.
Using X-Forward headers is only used in special use-cases such as involving reverse proxies.
The default library for the avro
data format has changed from Apache Avro to Jackson Avro. We also use Jackson as default for the JSon dataformat.
The interceptFrom
and interceptSentToEndpoint
EIPs is now storing the intercepted endpoint using key Exchange.INTERCEPTED_ENDPOINT
as exchange property instead of a header.
Before:
String uri = exchange.getIn().getHeader(Exchange.INTERCEPTED_ENDPOINT, String.class);
After:
String uri = exchange.getProperty(Exchange.INTERCEPTED_ENDPOINT, String.class);
The Camel Maven BOMs (camel-bom
and camel-spring-boot-bom
) has been changed to use hardcoded
Camel release versions to ensure the BOM is always correct.
The options camel.main.backlogTracing
, "camel.main.backlogTracingStandby
, and camel.main.backlogTracingTemplates
has been
moved into a new group camel.debug
with more options to configure the backlog tracer.
To enable backlog tracing you should now set camel.trace.enabled=true
instead of camel.main.backlogTracing=true
.
The @DevConsole
annotation has been enhanced to include more information.
Migrate from
@DevConsole("stub")
To
@DevConsole(name = "stub", description = "Browse messages on stub endpoints")
We also renamed the route-curcuit-breaker
console to circuit-breaker
.
The command camel generate rest
have removed all the shorthand arguments such as `-i -o
instead use the long names --input --output
.
The camel-jsonpath
will now work more similar as camel-jq
when you specify a resultType
and have a list of entities.
Before camel-jsonapath
would attempt to convert the List
to the given restultType
which often is not useable. What
users want is to be able to convert each entry in the list to a given type such as a POJO.
For example the snippet below select all books from a JSon document, which will be in a List<Map>
object where each
book is an entry as a Map
. Before Camel would attempt to convert List
to Book
which would not be possible.
From this release onwards, Camel will convert each entry to a Book
so the result is List<Book>
.
This is also how camel-jq
works.
.transform().jsonpath(".book", Book.class)
Routes created by Kamelets are no longer registered as JMX MBeans to avoid cluttering up with unwanted MBeans, as a Kamelet is intended to act like a Camel component, despite its implementation is Camel routes. This means that the number of routes listed from JMX will no longer include Kamelet routes.
The old behaviour can be enabled by setting registerRoutesCreateByKamelet=true
on the ManagementAgent
object. See more in the JMX documentation.
The camel-micrometer
have renamed tag serviceName
to kind
and use naming that indicate that its from Camel:
Before |
After |
serviceName="MicrometerEventNotifierService" |
kind="CamelExchangeEvent" |
serviceName="MicrometerMessageHistoryService" |
kind="CamelMessageHistory" |
serviceName="MicrometerRoutePolicyService" |
kind="CamelRoute" |
Due to Kamelets are changed to act more like a Camel component, and not expose internal details as JMX MBeans, then micrometer and metrics no longer include statistics for those Kamelet routes.
The old behaviour can be enabled by setting registerRoutesCreateByKamelet=true
on the ManagementAgent
object. See more in the JMX documentation.
Added context level metrics to camel-micrometer
. The metrics with key camel.route.policy
now include
tag eventType
that specifies if the metrics is for a route or the entire camel context.
You can turn off context level metrics, by setting contenxtEnabled=false
on the factory such as:
factory.getPolicyConfiguration().setContextEnabled(false);
This can also be done easily from application.properties
such as:
camel.metrics.routePolicyLevel=route
Dropped support for the old Swagger 2.0 spec. Only OpenAPI v3 specs is supported now. Fixed maven dependencies to be JakartaEE compatible.
When using Rest DSL and have api-doc
enabled via camel-rest
and camel-openapi-java
, then
the OpenAPI specification is now generated once during startup instead of on-demand when a client
calls the /api-doc
endpoint.
Added a Cookie Handler allowing the addition, retrieval and expiry of Cookies.