LibraryToggle FramesPrintFeedback

Miscellaneous Changes

Error handling

Apache Camel 2.2 uses the new DefaultErrorHandler, instead of the DeadLetterChannel (versions 1.x), as the default error handler. This new DefaultErrorHandler implementation does not catch and handle thrown exceptions, which means any exception thrown will be propagated back to the caller.

Since Apache Camel 2.5, onException clauses defined at RouteBuilder level must be defined before the routes, otherwise Apache Camel throws an exception while starting the routes.

Since Apache Camel 2.8, exceptions thrown while handling other exceptions in onException are now caught by a fallback error handler, which logs the second exception and propagates the second exception in the Exchange. The Exchange will then cease processing and fail immediately.

Stream caching

Stream caching is a feature that enables you to re-read a message body consisting of a stream type. The interaction between Apache ServiceMix and Apache Camel has now been modified in such a way that Apache Camel does not need to use stream caching. It is therefore disabled by default.

[Note]Note

If necessary, you can re-enable caching by adding the streamCaching() command to a route in the Java DSL or by setting the route element's streamCaching attribute to true in the Spring XML DSL.

Annotations

The following changes have been made to the Java annotations:

  • The name attribute in @EndpointInject has been changed to ref, in order to be consistent with the other annotations (where the @EndpointInject annotation references an Endpoint that gets looked up in the Registry).

  • Since Apache Camel 2.3, the spelling of the parallelProcessing attribute in @RecipientList has been fixed.

Case-insensitivity of header look-up

Since Apache Camel 2.0, header look-up in org.apache.camel.Message is case-insensitive. This means that if you look up a header using differently cased keys (such as Foo and foo), you will obtain a reference to the same header entry. This makes header look-up less error-prone when used with protocols such as HTTP, where header names are inherently case insensitive.

Round robin load balancing

The round robin load balancing behavior has changed in Apache Camel 2.2. In version 1.x, the round robin load balancer would fail over, if an endpoint failed to process the message. In version 2.2, the round robin load balancer does not fail over immediately, but tries to redeliver the message to the same endpoint, according to the error handling configuration.

[Note]Note

Apache Camel 2.3 will introduce an option that allows you to specify which behavior you want the endpoint to exhibit.

Splitter

Since Apache Camel 2.3, if the exchange that enters the splitter has the InOut message-exchange pattern (that is, a reply is expected), the splitter returns a copy of the original input message as the reply message in the Out message slot. To revert to the old (pre 2.3) behavior, configure the splitter to use the UseLatestAggregationStrategy aggregation strategy.

xpath language and XML conversions

Since Apache Camel 2.3, the NodeList to String converter has been improved to include XML tags and attributes. For example, the conversion can now produce strings like <foo id="123">bar<year>2015</year></foo>.

This change will affect code that relied on the old string conversion. For example, if you previously extracted strings from XML using @XPath annotations as in the following method signature:

// Java
// Camel version 2.2 or earlier:
public void credit(
        @XPath("/transaction/transfer/receiver") String name, 
        @XPath("/transaction/transfer/amount") String amount
        )

You must now explicitly specify the text() node, in order to avoid including the element tags in the string, as follows:

// Java
// Camel version 2.3 or later
public void credit(
        @XPath("/transaction/transfer/receiver/text()") String name, 
        @XPath("/transaction/transfer/amount/text()") String amount
        )

Converter character set

The character set used by Apache Camel converters can be set using the org.apache.camel.default.charset Java system property. The default is UTF-8.

CamelContext

Since Apache Camel 2.5, the following changes affect CamelContext:

  • Apache Camel fails to start up, if more than one CamelContext instance with the same ID is registered in JMX.

  • If you do not specify an ID value for a camelContext element, Apache Camel now assigns an automatically generated ID from the sequence, camel-1, camel-2, and so on. In previous Apache Camel versions, the ID value defaulted to the string, camelContext.

UuidGenerator

Since Apache Camel 2.5, Apache Camel supports the use of third party UUID generators. The default UUID generator is based on the same implementation used in Apache ActiveMQ, ActiveMQUuidGenerator. Some of the APIs required by this implementation (for example, the Google app engine) might not be accessible in all deployment contexts, in which case you should switch to another of the UUID generator implementations. The following implementations are provided:

  • org.apache.camel.impl.JavaUuidGenerator.

  • org.apache.camel.impl.SimpleUuidGenerator.

  • org.apache.camel.impl.ActiveMQUuidGenerator.

You can set the UUID generator in either of the following ways:

  • In the Java DSL, call the CamelContext.setUuidGenerator() method as follows:

    // Java
    getContext().setUuidGenerator(new MyCustomUuidGenerator());
  • In the Spring DSL, simply instantiate a bean of the requisite type. For example, to enable the JavaUuidGenerator:

    <bean id="javaUuidGenerator"
          class="org.apache.camel.impl.JavaUuidGenerator" />

JMX fails fast on start-up

Since Apache Camel 2.5, if there is a problem with starting the JMX service, Apache Camel will not start at all. In previous versions, if JMX failed, a warning was logged (at WARN level) and Apache Camel continued to start up without the JMX service. The problem with the old behavior is that it could lead to errors later on—for example, some J2EE servers might throw a security exception, if you try to access a JMX MBean server at run time when JMX has failed to start.

[Note]Note

Programmers who want to exploit the fail safe mechanism for custom features now have the option of raising the VetoCamelContextStartException exception, whenever the onContextStart() method is called back on the LifecycleStrategy interface.

Aggregator

Since Apache Camel 2.5, by default, the aggregator pattern uses a synchronous invocation to processes completed aggregated exchanges. This ensures that no internal task queue is used, effectively throttling the incoming stream of messages. To switch to asynchronous operation, enable the parallel processing option.

Maven archetypes

Since Apache Camel 2.7, the camel-archetype-war Maven archetype is renamed to camel-archetype-webconsole.

camel-spring-tests and camel-blueprint-tests artifacts

Since Apache Camel 2.8, the camel-spring-tests and the camel-blueprint-tests Maven artifacts are no longer being released to the Maven central repository.

pollEnrich

Since Apache Camel 2.8, pollEnrich now sets an empty message body, if the Content Enricher could not poll from the resource. Previously the old message body would be preserved.

Since Apache Camel 2.10, the pollEnrich DSL command now blocks, if no messages are available and no timeout has been configured.

Custom TypeConverter

Since Apache Camel 2.8, it is highly recommended that you modify the contents of the META-INF/services/org/apache/camel/TypeConverter file to specify the fully-qualified names of the type converter classes. This is much more efficient, because it makes it unnecessary to scan all of the Java packages to find the type converter classes at run time.

Camel test component

Since Apache Camel 2.9, debugger is now disabled by default in Camel Test. You would need to override the isUseDebugger() method and return true to enable it.

Simple language

Since Apache Camel 2.9, the Simple language has an improved syntax parser. Simple is now more strict and will report syntax errors for invalid input. For example, predicates now require literal text to be enclosed in quotes. The range operator also requires the range to be enclosed in quotes. For details, see The Simple Language in Routing Expression and Predicate Languages.

Since Apache Camel 2.10, the simple language no longer trims white space surrounding an expression in the Java DSL. On the other hand, the simple language does trims white space surrounding an expression in the XML DSL by default, but you can disable this behavior by setting trim="false" in the simple element.

URI normalization

Since Apache Camel 2.10, URI normalization now recognizes pre-existing %nn decimal encodings in URI strings.

Intercept

When using Apache Camel interceptors, the behavior when combining the skipSendToOriginalEndpoint() clause with the when() predicate has changed in Apache Camel 2.10.

Now, when you combine the skipSendToOriginalEndpoint() clause with a when() predicate, the original endpoint is skipped, only if the when() predicate evaluates to true. For example, in the following route, the mock:result endpoint will be skipped, only if the message body is equal to Hello World:

interceptSendToEndpoint("mock:foo")
    .skipSendToOriginalEndpoint()
    .when(body().isEqualTo("Hello World"))
    .to("mock:detour").transform(constant("Bye World"));

from("direct:second")
    .to("mock:bar")
    .to("mock:foo")
    .to("mock:result");

In previous versions, the original endpoint would have been skipped, even if the when() predicate evaluated to false.

Thread name pattern

Since Apache Camel 2.10, the default pattern for thread names is now:

Camel (#camelId#) thread ##counter# - #name#

In previous releases the thread name pattern was:

Camel (${camelId}) thread #${counter} - ${name}

Type converters

Since Apache Camel 2.10, the setting lazyLoadTypeConverter=true is now deprecated and will be removed in a future release. The recommended practice is to load type converters at start up time.

The Apache Camel test kit no longer lazily loads type converters.

Apache Camel now fails faster during type conversion, by throwing TypeConversionException to the caller.

Apache Camel no longer supports using java.beans.PropertyEditor for type conversion. This approach is slow, not thread safe, and uses third party JARs on the classpath, which can cause unwanted side effects.

MDC logging

Since Apache Camel 2.10, the keys for MDC logging are now prefixed with .camel.

Comments powered by Disqus