Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.


Available as of Camel 2.10

The BeanIO Data Format uses BeanIO to handle flat payloads (such as XML, CSV, delimited, or fixed length formats).

BeanIO is configured using a mappings XML file where you define the mapping from the flat format to Objects (POJOs). This mapping file is mandatory to use.








The BeanIO mapping file. The option is mandatory. Is by default loaded from the classpath. You can prefix with file:, http:, or classpath: to denote from where to load the mapping file.



The name of the stream to use. This option is mandatory.



Whether to ignore unidentified records.



Whether to ignore unexpected records.



Whether to ignore invalid records.


Platform default

The charset to use.



A custom BeanReaderErrorHandler implementation to use in your dataformat definition


An example of a mapping file is here.

Using Java DSL

To use the BeanIODataFormat you need to configure the data format with the mapping file, as well the name of the stream.
In Java DSL this can be done as shown below. The streamName is "employeeFile".

Then we have two routes. The first route is for transforming CSV data into a List<Employee> Java objects. Which we then split, so the mock endpoint
receives a message for each row.

The 2nd route is for the reverse operation, to transform a List<Employee> into a stream of CSV data.{snippet:id=e1|lang=java|url=camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/}The CSV data could for example be as below:{snippet:id=e2|lang=java|url=camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/}


To use the BeanIO data format in XML, you need to configure it using the <beanio> XML tag as shown below. The routes is similar to the example above.{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/SpringBeanIODataFormatSimpleTest.xml}


To use BeanIO in your Camel routes you need to add a dependency on camel-beanio which implements this data format.

If you use Maven you can just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).

xml<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-beanio</artifactId> <version>2.10.0</version> </dependency>
© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram