[CONF] Apache Camel: Composed Message Processor (page edited)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[CONF] Apache Camel: Composed Message Processor (page edited)

Dhiraj Bokde (Confluence)

Composed Message Processor has been edited by Jonathan Anstey (Feb 04, 2009).

(View changes)


Composed Message Processor

The Composed Message Processor from the EIP patterns allows you to process a composite message by splitting it up, routing the sub-messages to appropriate destinations and the re-aggregating the responses back into a single message.

Available in Camel 1.5.


In this example we want to check that a multipart order can be filled. Each part of the order requires a check at a different inventory.

// split up the order so individual OrderItems can be validated by the appropriate bean
    .when().method("orderItemHelper", "isWidget").to("bean:widgetInventory", "seda:aggregate")
    .otherwise().to("bean:gadgetInventory", "seda:aggregate");

// collect and re-assemble the validated OrderItems into an order again
from("seda:aggregate").aggregate(new MyOrderAggregationStrategy()).header("orderId").to("mock:result");

To do this we split up the order using a Splitter. The Splitter then sends individual OrderItems to a Content Based Router which checks the item type. Widget items get sent for checking in the widgetInventory bean and gadgets get sent to the gadgetInventory bean. Once these OrderItems have been validated by the appropriate bean, they are sent on to the Aggregator which collects and re-assembles the validated OrderItems into an order again.

For full details, check the example source here:


Using This Pattern

If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out.