...
Wiki Markup |
---|
{snippet:id=block|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/PipelineRouteBuilderTest.scala} |
Filter
Anchor | ||||
---|---|---|---|---|
|
For a message filter, use the when()
method with a parameter of type The Exchange ⇒ Boolean
. In the example below, we use a Scala convenience method named in
to access the 'in' message body; only messages where the 'in' message is <hello/>
will arrive at the mock:a
endpoint.
...
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
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=cbr|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ContentBasedRouterTest.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=simple|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala} |
Wiki Markup |
---|
{snippet:id=block|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala} |
The above examples also show you how other languages like XPath can be within the Scala DSL.
TODO
TODO: Create a Scala alternative and example for every EIP available on http://activemq.apache.org/camel/enterprise-integration-patterns.html
- Message Channel
- MessagePipes and Filters
- Message Router
- Message Translator
- Message Endpoint
- Point to Point Channel
- Publish Subscribe Channel
- Dead Letter Channel
- Guaranteed Delivery
- Message Bus
- Correlation IdentifierContent Based Router
- Message Filter
- Recipient ListSplitter
- Aggregator
- Resequencer
- Routing Slip
- Throttler
- Delayer
- Load Balancer
- Multicast
- 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