I have a message carrying XML (an order) containing multiple homogenous nodes (think a list of products) in addition to other info (think address, customer details, etc.). I have to enrich each ‘product’ with details provided by another external service and return the same complete XML ‘order’ message with enriched ‘products’.
I came up with this sequence of steps:
- Split the original XML with xpath to separate messages (also keeping the original message)
- Enrich split messages with additional data
- Put enriched parts back into the original message by replacing old elements.
I was trying to use multicast by sending original message to endpoint where splitting and enriching is done and to aggregation endpoint where original message and split-enriched messages are aggregates and then passed to processor which is responsible for combining these parts back to single xml file. But I couldn’t get the desired effect…
What would be the correct and nice way to solve this problem?
The Splitter EIP in Camel can aggregate messages back (as a Composed Message Processor EIP).
http://camel.apache.org/splitter
See this video which demonstrates such a use-case
http://davsclaus.blogspot.com/2011/09/video-using-splitter-eip-and-aggregate.html