Using camel-bindy to parse a multi line file
Environment
- Red Hat JBoss Fuse 6.0
Issue
- Is it possible to use
camel-bindyto parse a multi line file with different record types on each line, each line binding to a different POJO? - From examples I have seen, the
@linkannotation would only be used if there were two classes defined on a single line.
Resolution
The current implementation of the camel-bindy component does not parse multiple line in the CSV file where each line could be bound to a different POJO. The reason is that CSV to object mapping is based on the position and the the objects are mapping per lines. However there are some workarounds that could help achieving the desired behavior.
- Transform and combine multi lines into a single line and then use
@linkannotation to link this line to a different POJOs basically creating the scenario to match the current behavior of the bindy. - Another approach could be to use Camel BeanIO component that can handle some twisted multi-line mappings. See section 4.2. Records.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
