Versions Compared

Key

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

...

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

Message routing

Aggregator

The aggregator EIP aggregates messages based on some message correlation criteria. In the Scala DSL, the aggregate method takes a function Exchange ⇒ Any to determine the correlation value for the exchange. In both samples below, message are being aggregated if the first 7 letters in the message body are the same.

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

Content based router

Similar to the Filter , the content based router uses when methods with Exchange ⇒ Boolean function literals and an optional otherwise. The function literal can contain plain Scala code as well as any of the supported languages . The example below routes a given message based on the language of the message body.

...

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

Resequencer

Use the resequence method to add a resequencer to the RouteBuilder. The method takes a function (Exchange ⇒ Unit) that determines the value to resequence on. In this example, we resequence messages based on the 'in' message body.

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

The same EIP can also be used with a block-like syntax...

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

... and with configurable batch size. In this last example, messages will be send to mock:e whenever a batch of 5 messages is available.

Wiki Markup
{snippet:id=batch|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ResequencerTest.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.

...

  • 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
  • AggregatorResequencer
  • Routing Slip
  • 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