Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Camel Splitter EIP to process xml file

$
0
0
I have a requirement to stream an xml file from a server <streamXMLFile> and
divide the original xml to sub xml files based on a tag and also to extract
the value of a particular xml tag path from the splitted xml's then to
create a map with the extracted value and the split xml file <recordBuilder>
and put all the maps of each split to a list.

/ <route id="processXMLFiles">
<from uri="ref:activemqQueue" />
<process ref="processFileReadyMessage" />
<process ref="streamXMLFile" />
<split>
<tokenize token="snapshotRecord" xml="true" />
<setHeader headerName="subscriberId">
<xpath
resultType="java.lang.String">/superTagName/subTagName/@attributeName</xpath>
</setHeader>
<process ref="recordBuilder" />
<process ref="anotherProcessor"/>
<process ref="anotherProcessor"/>
</split>
</route>/

As the <recordBuilder> process is inside the split tag i'm getting each
split xml file and i have a if condition in the <recordBuilder> to check
the split size set the created list of maps inside the exchange body as:

if (splitSize == recordNumber) {
exchange.getOut().setBody(snapshotList);
}/

while this condt is not meet the next processor is invoked with an empty
exchange body.

if i put the processors outside the split tag, i get the bytestream exchange
body which is actually the output of the <streamXMLFile> process.

How do i make sure i send the list of maps to the successive processors only
after i create the list fully with all the xml splits.

Viewing all articles
Browse latest Browse all 5648

Trending Articles