BeanIOPage edited by Claus IbsenChanges (6)
Full ContentBeanIOAvailable 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. Options
UsageAn example of a mapping file is here. Using Java DSLTo use the BeanIODataFormat you need to configure the data format with the mapping file, as well the name of the stream. 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 The 2nd route is for the reverse operation, to transform a List<Employee> into a stream of CSV data. Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20
The CSV data could for example be as below: Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20
Using XML DSLTo 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="http://camel.apache.org/schema/spring"> <!-- setup beanio data format --> <dataFormats> <beanio id="myBeanio" mapping="org/apache/camel/dataformat/beanio/mappings.xml" streamName="employeeFile"/> </dataFormats> <route> <from uri="direct:unmarshal"/> <unmarshal ref="myBeanio"/> <split> <simple>body</simple> <to uri="mock:beanio-unmarshal"/> </split> </route> <route> <from uri="direct:marshal"/> <marshal ref="myBeanio"/> <to uri="mock:beanio-marshal"/> </route> </camelContext> DependenciesTo use BeanIO in your camel routes you need to add the a dependency on camel-beanio which implements this data format. If you use maven you could 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). <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-beanio</artifactId> <version>2.10.0</version> </dependency>
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > BeanIO confluence
- [CONF] Apache Camel > BeanIO confluence
