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
API changes
The class org.apache.camel.impl.engine.ValidatorKey
moved to org.apache.camel.spi.ValidatorKey
. The class org.apache.camel.impl.engine.TransformerKey
moved to org.apache.camel.spi.TransformerKey
.
The org.apache.camel.spi.RestRegistry
method addRestService
has added boolean contractFirst
parameter to define if the Rest service is contract-first or code-first.
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.
The statistics collector in the registry has been made immutable. As such, enabling collection of statistics has to be done prior to creating the type converter 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.
The SupervisingRouteController
has now been pre-configured to report DOWN
during restart attempts, and also when giving up starting a route. It is the UnhealthyOnExhausted
and UnhealthyOnRestarting
options that have been changed to be default true
. To have previous behavior you can set these options to false
.
camel-cloud
The camel-cloud component has been deprecated.
camel-crypto
PGP dataformat functionality was extracted from camel-crypto
JAR and placed into camel-crypto-pgp
.
DSL
The WireTap EIP in copy mode, will now do a deep-copy if the message body is of StreamCache
type to make access to the message body thread-safe.
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-file
When using idempontent=true
then the file consumer will now run in eager mode, and add
the file to the repository before processing, and call confirm
when done. Setting idempontentEager=false
will use the old behaviour.
camel-jbang
The generate
commands has been moved into separate plugin which you need to install first to be able to use.
camel plugin add generate
You can see list of available plugins using camel plugin get --all . |
camel-jetty / camel-servlet / camel-undertow
When using embedded HTTP server (consumer) then the headers CamelHttpServletRequest
and CamelHttpServletResponse
has been removed.
To gain access to these then you need to use the HttpMessage
API instead as shown below:
ServletRequest request = exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST, ServletRequest.class);
ServletResponse request = exchange.getIn().getHeader(Exchange.HTTP_SERVLET_RESPONSE, ServletResponse.class);
Should be changed to:
ServletRequest request = exchange.getMessage(HttpMessage.class).getRequest();
ServletResponse response = exchange.getMessage(HttpMessage.class).getResponse();
camel-seda / camel-disruptor
When using InOnly
exchange pattern then the producer makes a copy of the message to be added to the queue. Camel will now do a deep-copy if the message body is of StreamCache
type to make access to the message body thread-safe.
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-hashicorp-vault
The HashicorpVaultPropertiesFunction
from the hashicorp vault has been changed to avoid declaring statically the Vault Engine.
This means the camel.vault.hashicorp.engine
property and the support for CAMEL_HASHICORP_VAULT_ENGINE
environment variable have been removed.
You can now use the following syntax:
hashicorp:engine:secret
Where engine will be the Hashicorp Vault Engine to be used. This means you’ll be able to use multiple engines at the same time. More details at CAMEL-20775 issue.
camel-test
As part of CAMEL-20785, we have started to rework the CamelTestSupport
class. At this point, it should be highly compatible with previous versions, as we are laying down the foundations for greater cleanups in the future. However, several methods have been marked as deprecated. Users of this class are advised to look at the deprecation notices and adjust the code accordingly.
camel-pubnub
Upgraded PubNub client from v6 to v9 and the wherenow
operation is removed due to no longer present in the client.
camel-as2
The camel-as2
component has been updated so that the client can compress a MIME body before signing or compress a MIME body before signing and encrypting as described in sections 3.2 and 3.5 of rfc 5402.
When the AS2 server is configured with a decryption key all received messages require encryption otherwise the server will return an 'insufficient-security' error disposition. Only messages with valid encryption will be successfully processed, for instance, 'encrypted', 'signed-encrypted', 'encrypted-compressed', 'encrypted-compressed-signed' and 'encrypted-signed-compressed' message types.
Messages that cannot be successfully decrypted will return a 'decryption-failed' error disposition. This includes messages encrypted with a invalid key or if the server receives encrypted messages but is not configured with a decryption key.
When the AS2 server is configured with a message signature validation certificate chain all received messages require a signature otherwise the server will return an 'insufficient-security' error disposition. Only messages with a valid signature will be processed, for instance, 'signed', 'compressed-signed', and 'signed-compressed' message types.
The server will return an 'authentication-failure' error when a message fails signature validation.
When the AS2 server is configured with a message signature validation certificate chain and a decryption key all received messages require encryption and a signature otherwise the server will return an 'insufficient-security' error disposition. Only messages with a valid signature and encryption will be processed, for instance, 'signed-encrypted', 'encrypted-compressed-signed', and 'encrypted-signed-compressed'.
signing cert | no | yes | no | yes |
decryption key | no | no | yes | yes |
plain | insufficient-security | insufficient-security | insufficient-security | |
signed | insufficient-security | insufficient-security | ||
encrypted | decryption-failure | decryption-failure | insufficient-security | |
signed-encrypted | decryption-failure | decryption-failure | ||
plain-compressed | insufficient-security | insufficient-security | insufficient-security | |
compressed-signed | insufficient-security | insufficient-security | ||
signed-compressed | insufficient-security | insufficient-security | ||
encrypted-compressed | decryption-failure | decryption-failure | insufficient-security | |
encrypted-compressed-signed | decryption-failure | decryption-failure | ||
encrypted-signed-compressed | decryption-failure | decryption-failure |
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
.