Splitting a message, and processing and gathering responses camel

Topics: Subroutine, C, Java Pages: 3 (498 words) Published: May 26, 2014
This recipe will show you how you how to split a message into individual fragments, process each fragment individually, and re-aggregate the processed exchanges back into a single exchange. In EIP terms, this is known as a Composed Message Processor, and is made up of a combination of a Splitter and an Aggregator.

How to do it...
In order to split and aggregate (join) a message, combine a split DSL statement with an associated congy as follows:
1. Define an AggregationStrategy instance as described in the Aggregating related messages recipe. For this example, we will reuse theSetAggregationStrategy implementation from that recipe:

2. Define a regular split block as per the Splitting a message into fragments recipe, breaking up the payload as you see fit through the use of an expression. Reference the AggregationStrategy instance through the strategyRef attribute in the split element:

${body}

In the Java DSL, refer to the AggregationStrategy instance as the second parameter to the split() statement: from("direct:in")
.split(body(), new SetAggregationStrategy())
.inOut("direct:someBackEnd")
.end()
.to("mock:out");
How it works...
When an exchange reaches the split statement, it is broken up into individual fragments as expected, each of which is processed through the steps defined within the block. When each split fragment's exchange reaches the end of the split block, it is passed into theAggregationStrategy for aggregation. When all of the fragments have been processed, the final aggregated message proceeds down the route from the split block. This is different from the normal Splitter behavior, which forwards the original message to that statement after the split statement. Tip

By default, all processing is performed by a single thread. You can parallelize the processing of each message fragment by using theparallelProcessing option as described in the Processing split messages in parallel recipe. There's more......
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • The Gathering Essay
  • The Gathering Essay
  • Essay on The Gathering
  • Message Essay
  • Essay about Message
  • Gathering Blue Response to Literature Essay
  • Essay on The Gathering Text Response
  • Essay on Camel

Become a StudyMode Member

Sign Up - It's Free