This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch opt-exchangekey in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6b1d1258eeb5a0247950f82d46336ff9205bae8c Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Mar 12 07:21:48 2021 +0100 CAMEL-16326: camel-core - Optimize usage of exchanage properties for state in routing engine. --- .../ROOT/pages/camel-3x-upgrade-guide-3_9.adoc | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc index 4ec1701..29e53c8 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc @@ -9,28 +9,41 @@ from both 3.0 to 3.1 and 3.1 to 3.2. === API changes The `Consumer` API in `camel-api` has been enhanced to help support Camel reducing the footprint during routing. -One aspect is that we allow to recycle `Exchange` instances created by the consumers. This avoids creating new `Exchange` +One aspect is that we allow recycling `Exchange` instances created by the consumers. This avoids creating new `Exchange` instances in the memory for each incoming message consumers process. By recycling `Exchange`s we reduce the overhead -on the JVM garbage collector. However this requires Camel to know whether or not the `Exchange` should be recycle or not, +on the JVM garbage collector. This requires Camel to know if the `Exchange` should be recycled or not, and some API changes took place. The `Consumer` API has two new methods which a consumer must use to create an `Exchange` with `createExchange`. -By default the exchange is auto released when its complete in use, but some consumers needs custom control, +Default the exchange is auto released when its complete in use, but some consumers needs custom control, and can turn off auto release, which then requires the consumer to manually release the exchange by calling `releaseExchange` when the consumer is done with the exchange. The default implementations in `DefaultConsumer` has adapted this API and 3rd party components can continue as is, by using -the older APIs. However for these 3rd party components to support recycling exchanges, then they must be updated to use this new API. +the older APIs. For these 3rd party components to support recycling exchanges, then they must be updated to use this new API. -A new `org.apache.camel.spi.ResourceLoader` has been introduced as part of https://issues.apache.org/jira/browse/CAMEL-16285[CAMEL-16285] which provide a way to support additional schemas to resolve resources. As a conseguence: +A new `org.apache.camel.spi.ResourceLoader` has been introduced as part of https://issues.apache.org/jira/browse/CAMEL-16285[CAMEL-16285] which provide a way to support additional schemas to resolve resources. As a consequece: - `org.apache.camel.support.ResourceHelper` has been updated to use such mechanism instead fo the old one. - it is not more possible to provide support for additional schemas using the URL protocol handler mechanism but instead, custom schemas can be added by implementing `org.apache.camel.spi.ResourceResolver` and either bind an instance to the Camel Registry (using `resource-loader-` as a prefix) or using the Service Factory mechanism (under the path `META-INF/services/org/apache/camel/resource-resolver/`) -+ + As example, assuming you want to provide a support for the schema `foo`, then you either have to binbd your instance to the Camel Registry with `resource-loader-foo` as a key, or create a factory finder file with path `META-INF/services/org/apache/camel/resource-resolver/foo` -- the method for retrieving a resource URL provided by the `org.apache.camel.support.ResourceHelper` class, i.e. `resolveMandatoryResourceAsUrl` ad ` resolveResourceAsUr` have been amended to accept a `CamelContext` instance instead of a `ClassResolver`. +The method for retrieving a resource URL provided by the `org.apache.camel.support.ResourceHelper` class, i.e. `resolveMandatoryResourceAsUrl` ad ` resolveResourceAsUr` have been amended to accept a `CamelContext` instance instead of a `ClassResolver`. + +=== Exchange properties + +The properties on `Exchange` have been optimized to separate into two: internal state vs user properties. + +The method `getProperties()` now only returns user properties. To include internal properties as well, +then use `getAllProperties()`. + +The other APIs such as `getProperty(String)` works the same way as before, being able to lookup a property +regardless if its internal or custom. -resource-loader- +The internal properties is a fixed set of known keys defined in the `ExchangePropertyKey` enum class. +These keys are used in camel-core such as the routing engine, EIPs and others that needs to store internal +state on the `Exchange` which is done as exchange properties. Because Camel end users can also store +exchange properties then before they would get mixed together. What we have done now is to separate them. === Modularized camel-spring @@ -39,7 +52,7 @@ The `camel-spring` component has been modularized into: - `camel-spring` - Core module for Camel Spring support - `camel-spring-xml` - XML DSL when using Spring XML (eg `<beans>`) -And also for Camel on Spring Boot: +Also for Camel on Spring Boot: - `camel-spring-boot-starter` - Camel with Spring Boot - `camel-spring-boot-xml-starter` - XML DSL when using Spring XML (eg `<beans>`) with Spring Boot