Apache Camel 4.x Upgrade Guide
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.
Upgrading Camel 4.6 to 4.7
camel-core
Add default values to ThrottlingExceptionRoutePolicy
route policy.
The EndpointRegistry
interface has been slightly changed to now directly extends Map<NormalizedEndpointUri, Endpoint>
instead of being a parameterized type. This may cause some compilation failures if the code is declaring a variable for the registry.
camel-health
Routes which has are set to not auto-startup are reported as UP in health-checks. We have now implemented similar logic for the consumer health check as well (the route and consumer health check are linked together).
Previously a route that has not been started due to auto-startup=false
would still have its consumer health-check being executed, which could lead to DOWN due to consumer failing the check.
DSL
The Load Balancer EIP has aligned naming and the following balancers has been renamed in XML and YAML DSL:
Old Name | New Name |
---|---|
failOver | failOverLoadBalancer |
random | randomLoadBalancer |
roundRobin | roundRobinLoadBalancer |
sticky | stickyLoadBalancer |
topic | topicLoadBalancer |
weighted | weightedLoadBalancer |
For example in XML you need to change from:
<route>
<from uri="direct:start"/>
<loadBalance>
<failover>
<exception>java.io.IOException</exception>
</failover>
<to uri="direct:x"/>
<to uri="direct:y"/>
<to uri="direct:z"/>
</loadBalance>
</route>
To:
<route>
<from uri="direct:start"/>
<loadBalance>
<failoverLoadBalancer>
<exception>java.io.IOException</exception>
</failoverLoadBalancer>
<to uri="direct:x"/>
<to uri="direct:y"/>
<to uri="direct:z"/>
</loadBalance>
</route>
camel-debug
The debugger (using org.apache.camel.spi.BacklogDebugger
) used for tooling such as IDEA and Visual Studio, is fixed to work better out-of-the-box by just having camel-debug
JAR or camel-debug-starter
(for Spring Boot) on the classpath.
An internal change is that the MBean operation messageHistoryOnBreakpointAsXml
on ManagedBacklogDebugger
now includes the current node as last message history, which was expected by IDEA tooling, to make it function again.
camel-spring-security
The camel-spring-security
component has been updated to improve readiness for Spring Security 7.x. Since Spring Security 5.8 the AccessDecisionManager
interface and the related cooperating classes have been deprecated in favor of AuthorizationManager
based patterns. If you are creating Spring Security route policies in your code, you must now refactor them to be based on an AuthorizationManager
.
For example, you might have a route policy defined as follows:
SpringSecurityAuthorizationPolicy authorizationPolicy = new SpringSecurityAuthorizationPolicy();
authorizationPolicy.setAuthenticationManager(authenticationManager);
authorizationPolicy.setSpringSecurityAccessPolicy(new SpringSecurityAccessPolicy("ROLE_ADMIN"));
authorizationPolicy.setAccessDecisionManager(new AffirmativeBased(Collections.singletonList(new RoleVoter())));
With the changes implemented in this release, that must be refactored to:
SpringSecurityAuthorizationPolicy authorizationPolicy = new SpringSecurityAuthorizationPolicy();
authorizationPolicy.setAuthenticationManager(authenticationManager);
authorizationPolicy.setAuthorizationManager(AuthorityAuthorizationManager.hasRole("ADMIN"));
This new pattern supports a more expressive language to define your own authorization rules, exposing the full power of the Spring Security framework to Camel route policies. See the spring documentation for further details on how to migrate your custom code from AccessDecisionManager
to AuthorizationManager
.
camel-cloudevents
Moved the camel-cloudevents
api into camel-api
and removed the camel-cloudevents
dependency from all components that provide CloudEvent transformers.
Camel Spring Boot
camel-debug-starter
Using camel debugger with Spring Boot is now moved from camel-spring-boot
into camel-debug-starter
where you can configure the debugger via camel.debug.
options in application.properties
.
The camel-debug-starter
now has camel.debug.enabled=true
by default to let the debugger be installed out of the box, by having the JAR on the classpath (as intended). You can turn this off via camel.debug.enabled=false
.