Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It would be good to have a camel-java8-dsl component that offers a JDK8 DSL which uses all the nice new stuff from JDK8 with higher order functions, closures, et all.
Though this may comes later in Camel 3.x when JDK8 is GA.
At least stuff like Predicate, Expression, AggregationStrategy etc. are "functional interfaces" (containing only one method) and Java 8 applications can implement them using lambdas. That's only a start, but it doesn't require a specific DSL.

Routing Core Re-engineering (raulk)

The routing core of Camel 2.x is heavily based on a recursive call pattern, where Processors are responsible for calling the next one along the chain. This results in lengthy and meaningless stacktraces (difficult to make sense out of and debug for newcomers) and higher memory usage due to retention of local variables for a longer time than strictly needed.

Moreover, Camel weaves a large number of "plumbing" processors along the way which should not really be processors because they form part of the very essence of the routing core, e.g. error handlers, stream caching interceptors, trace interceptors, async processor helpers, MDC, etc.

The proposal is to shift towards an iterative model, by redesigning the logic of Camel routing. The suggested model is defined by these pillars:

  • A single class, or a limited set of them, contain the routing logic of Camel. Package name: org.apache.camel.core.routing. Central (abstract) class: RoutingCore. Concrete realisations could be: PipeliningRoutingCore, MulticastRoutingCore, depending on the fundamental routing pattern.
  • The RoutingCore iteratively calls the routing steps, one after another. The routing steps return their result to the RoutingCore, who is in charge of calling the next element subsequently. OUT and IN are bridged if necessary (PipeliningRoutingCore).
  • The Processor interface is crumbled up into its many specialisations, each of which represents a distinct concept of the Camel framework: RoutingDecider (EIPs should only take decisions about the routing, but not perform the routing itself, e.g. choice, filter, loop, throttle, etc.; see examples in subsection below.), Actions, ErrorHandler (already exists), Interceptor, etc.
  • The RoutingCore is responsible of all the "magic" now disseminated across a number of processors. Assisted by Helper classes.

The goal of this idea isn't to zap off recursion altogether, just to consolidate the routing logic into a handful of cornerstone classes.

Camel is no longer a baby and the framework concepts are well mature, thus they should be transferred to the API and avoid making everything a raw Processor.

Converting some EIPs from "executors" to "deciders"

  • choice() => evaluates the predicates and returns the List of Processors or Endpoints to invoke.
  • filter() => same as choice(), but returning null if the filter doesn't match, to continue to the next routing step.
  • loop() => evaluates whether the looping control predicate still stands. If yes, it returns the processors to invoke, where the last is itself (to trigger the looping logic again); else, it returns null to continue to the next routing step.
  • throttle() => pauses accordingly and then returns the endpoint/processors to invoke.
  • ...

Clearer Architecture of Camel Core

...