Welcome to Babel’s documentation!

_images/logo-without-pole.png

Babel is an elegant way to write your integration solution. It tries to provide as much as possible validation during the definition of your integration solution in order to avoid time spent into testing or deploying invalid code.

Babel is a layer on top of the main integration frameworks and may be used from Scala and Java source code. The following documentation should guide you into your journey toward a new way to write integration in a secure and efficient way.

Currently, Babel provides an API on top of Apache Camel which may be used in Scala. Java API and other integration frameworks implementation would be implemented into the Babel experimental project.

Modular

Babel provides extension which may get composed in order to add specific functionalities.

Typed

Babel provides typing validation all along your routes.

Functional

Babel allows you to use functions to configure your integration solution.


Multi languages

Babel provides API for both Java and Scala.

Integration

Babel aggregates main knowledge and technologies around EIPs such as modeled by Apache Camel and Spring Framework Integration

OSGi integrated

Babel may run into OSGi environment and is also packaged for Apache Karaf.


This documentation concerns the version 0.8.0. You may also access the previous released version documentation.

To use Babel on top of Camel, you may use the Babel Camel module. Please have a look to the Quick start guide and to the Babel Camel User guide for more details and examples.

To have a better intuition of what is Babel, you would find it in the Babel Opinion and the Babel Architecture pages.

In the following code snippet, we compare Babel and Camel Scala DSL. Those two routes are summing the a list of number, provided as a String and routing this sum depending on its positivity.

Babel sample Camel scala sample
import io.xtech.babel.camel.builder.RouteBuilder

val myRoute = new RouteBuilder {
  from("direct:babel").requireAs[String].
    splitBody(_.split(",").map(_.toInt).iterator).

    aggregate(doAggregate).

    choice { c =>
      c.whenBody(_ > 0).
        to("mock:database")

      c.whenBody(_ < 0).
        processBody(int => s"$int is negative").
        to("mock:error")
    }
}
import org.apache.camel.scala.dsl.builder.RouteBuilder

val routing = new RouteBuilder {
  from("direct:camel-scala").
    split(msg => msg.in[String].split(",")).

    aggregate("a", aggregationStrategy).completionSize(3).

    choice {
      when(_.in[Int] > 0).
        to("mock:database-camel-scala")

      when(_.in[Int] < 0).
        process(msg => msg.in = s"${msg.in} is negative").
        to("mock:error-camel-scala")
    }
}
Concerning the route structure, the main aspect is the fact we need to repeat the type everywhere. Moreover, you may also use pure functions in the Babel Code where you need mutability in the Camel Scala process method call. Let’s have a look at how aggregation is configured:
val doAggregate = ReduceBody(
  //defines how message bodies are aggregated
  (a: Int, b: Int) => a + b,
  //defines when message may be aggregated
  (msg: Message[Int]) => "a",
  //defines the size of the aggregation (3 messages)
  completionStrategies = List(CompletionSize(3))
)
val aggregationStrategy = new AggregationStrategy {
  def aggregate(old: Exchange, news: Exchange) =
    (Option(old), Option(news)) match {
      case (Some(old), None)  => old
      case (None, Some(news)) => news
      case (Some(old), Some(news)) =>
        old.getIn.setBody(
          old.getIn.getBody(classOf[Int]) +
            news.getIn.getBody(classOf[Int]))
        old
    }
}
Babel Camel has add simple interfaces in order to simplify and concentrate your code: The trivial behavior for first and last input is more clear using a Reduce or a Fold pattern. Moreover, the correlation and the completion is define in a single place which makes the aggregation more uniform.
   

In the following documentation,

  • Keywords are written such as from, to or process
  • Classes, packages, modules are written such as RouteBuilder or io.xtech.babel

In the following sections,