Versions Compared

Key

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

...

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

Multicast

Multicast allows you to send a message to multiple endpoints at the same time. In a simple route, you can specify multiple targets in the to or method call:

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

You can also explicitly define an explicit multicast in your RouteBuilder:

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

Splitter

To handle large message in smaller chunks, you can write a Scala Exchange ⇒ Any* method and add it to your route with the splitter method. As with many other EIPs, we support a short, in-line version as well as a more elaborate block based one.

...

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

Message transformation

Content enricher

Using a processor function (Exchange → Unit), you can alter/enrich the message content. This example uses a simple function literal to append " says Hello" to the message content:

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

However, you can also define a separate method/function to handle the transformation and pass that to the process method instead. The example below uses pattern matching to enrich the message content:

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

Off course, you can also use any other Camel component (e.g. Velocity) to enrich the content and add it to a pipeline

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

TODO

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

  • Message Channel
  • Message
  • Message Router
  • Message Translator
  • Message Endpoint
  • Point to Point Channel
  • Publish Subscribe Channel
  • Dead Letter Channel
  • Guaranteed Delivery
  • Message Bus
  • Correlation Identifier
  • Aggregator
  • Resequencer
  • Routing Slip
  • Throttler
  • Delayer
  • Load BalancerMulticast
  • Content Enricher
  • Content Filter
  • Normalizer
  • Messaging Mapper
  • Event Driven Consumer
  • Polling Consumer
  • Competing Consumers
  • Message Dispatcher
  • Selective Consumer
  • Durable Subscriber
  • Idempotent Consumer
  • Transactional Client
  • Messaging Gateway
  • Service Activator
  • Wire Tap