Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Warning
titleWork in progress

The Scala DSL for Apache Camel is currently under development and it only supports part of what is available in the Java-based DSL or Xml Configuration syntax.

About the Scala DSL

Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It integrates very well with the Java platform. Our Scala DSL implementation is built on top of the existing Java-based DSL, but it adds Scala syntax sugar to make building routes even more convenient.

Getting started

...

Documentation

...

Wiki Markup
{snippet:id=basic|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/BasicRouteBuilderTest.scala}

If you compare this to the Java DSL, you notice:

  • there is no configure() method to override
  • a route starts directly with a URI instead of from(uri)
  • is just an alias for to

References

Enterprise integration patterns

Pipeline

There is a simple syntax available for specifying pipeline, by simple putting to or &rarr between the different steps in the pipeline.

Wiki Markup
{snippet:id=simple|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala}

For more advanced use cases, you can also use a block-based syntax.

Wiki Markup
{snippet:id=block|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala}

TODO

TODO: Create a Scala alternative and example for every EIP available on http://activemq.apache.org/camel/enterprise-integration-patterns.htmlImage Removed

...

Dependencies

To use the Scala DSL in your camel routes you need to add the a dependency on camel-scala which implements the Scala DSL.

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).

Code Block
xml
xml

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-scala</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

Starting from version 2.11 Camel Scala DSL is compiled against Scala 2.10. If you plan to use Scala 2.9 with Camel 2.11, add the following to your pom.xml file instead.

Code Block
xml
xml

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-scala_2.9</artifactId>
  <version>2.11.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

Support for Scala 2.9 is deprecated and will be removed starting from the Camel 2.12 and 3.0.

...