...
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
Delayer
Unlike a throttler, which only slows down messages if the rate exceeds a treshold, a delayer delays every messages with a fixed amount of time. An example: to delay every message going from seda:a
to mock:a
with 1 second, you write...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/PipelineAndMulticastTestDelayerTest.scala} |
You can also explicitly define an explicit multicast
in your RouteBuilder
:Our second example will delay the entire block (containing mock:c
) without doing anything to mock:b
Wiki Markup |
---|
{snippet:id=multicastblock|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ExplicitMulticastTestDelayerTest.scala} |
...
Load balancer
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.distribute the message handling load over multiple endpoints, we add a loadbalance
to our route definition. You can optionally specify a load balancer strategy, like roundrobin
Wiki Markup |
---|
{snippet:id=loadbalance|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/LoadBalancerTest.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/SplitterRouteBuilderTestPipelineAndMulticastTest.scala} |
You can also explicitly define an explicit multicast
in your RouteBuilder
:
Wiki Markup |
---|
{snippet:id=blockmulticast|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTestExplicitMulticastTest.scala} |
...
Recipient list
You can handle a static recipient list with a multicast or pipeline , but this EIP is usually applied when you want to dynamically determine the name(s) of the next endpoint(s) to route to. Use the recipients()
method with a function literal (Exchange => Any
) that returns the endpoint name(s). In the example below, the target endpoint name can be found in the String message starting at position 21.
...
Wiki Markup |
---|
{snippet:id=block|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/RecipientListRouteTest.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.
Throttler
The throttler allows you to slow down messages before sending them along. The throttle
methods allows you to specify the maximum throughput rate of message:
Wiki Markup |
---|
{snippet:id=simple|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ThrottlerTest.scala} |
It can also be used in front of block to throttle messages at that point. In the example below, message are passed on to mock:b
in a normal rate (i.e. as fast as possible), but a maximum 3 messages/2 seconds will arrive at the mock:c
endpoint.
Wiki Markup |
---|
{snippet:id=block|lang=java|url=activemq/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/ThrottlerTest.scala} |
Message transformation
Content enricher
...
- 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 Balancer
- 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