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.


Option Default Description
mapping 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.
streamName The name of the stream to use. This option is mandatory.
ignoreUnidentifiedRecords false Whether to ignore unidentified records.
ignoreUnexpectedRecords false Whether to ignore unexpected records.
ignoreInvalidRecords false Whether to ignore invalid records.
encoding Platform default The charset to use.


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.

                // setup beanio data format using the mapping file, loaded from the classpath
                DataFormat format = new BeanIODataFormat(

                // a route which uses the bean io data format to format a CSV data
                // to java objects
                    // and then split the message body so we get a message for each row

                // convert list of java objects back to flat format

The CSV data could for example be as below:

    private static final String FIXED_DATA =
            "Joe,Smith,Developer,75000,10012009" + LS
            + "Jane,Doe,Architect,80000,01152008" + LS
            + "Jon,Anderson,Manager,85000,03182007" + LS;


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.

  <camelContext xmlns="">
    <!-- setup beanio data format -->
      <beanio id="myBeanio" mapping="org/apache/camel/dataformat/beanio/mappings.xml" streamName="employeeFile"/>

      <from uri="direct:unmarshal"/>
      <unmarshal ref="myBeanio"/>
        <to uri="mock:beanio-unmarshal"/>
      <from uri="direct:marshal"/>
      <marshal ref="myBeanio"/>
      <to uri="mock:beanio-marshal"/>


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).