I am trying to code a Camel batch :
- process all files inside a specific directory and for each file :
- validate the XML with a XSD schema
- unmarshall different parts and process data
- don't stop on exception
- if a least one error occurs, move to failed dirrectory at the end, move to done otherwise
The difficulties I encounter :
- File Component allow to automatically move file on done/failed directory but as soon as you use of split/aggregator, the file is always moved in done and don't even wait the aggregation finished.
- Managing Exception is not intuitive
- Split and aggretors are nightmare and there is not enough "real world" examples in documentation
- XML tokenization on complex structure brings us to something beyond understanding
Of course, I meet these problems because I am new to Apache Camel :)
The idea of what I am trying to do :
- File Component (ok)
- XSD validation (ok, if error, File component move to failed)
- make many splits/multicast to read XML, when a error occurs, we ignore exception, keep a header in error, and continue (not really ok, I can read but don't manage to aggregate correctly)
- we aggregate (in fact nothing to aggregate, we just want to check all headers)
- if error, we explicitely move to a failed directory
Simplified XML for this example :
<root>
<library></library>
<books year="2015">
<book></book>
<book></book>
... many
</books>
<books year="2016">
<book></book>
<book></book>
... many
</books>
... many years
</root>
How would you construct the batch with such an XML ? Moreover, let's say you have to read "library" before anything else (and use pipeline). Also, is the idea of saving error in header (boolean) good ?
Note: Special thanks to Claus Ibsen who responds to many Camel posts on SO, but also, please try to not just give a simple link on the Apache Camel documentation :) Really, for newbies, Apache Camel documentation sux.
Thanks