Hey Guys
I was creating a POC which reads a CSV file with following content
*reji,mathews,2681,pass
jack,rose,261,fail
The class defined is as follows
package com.poc.camel.csv.java.bindy;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
@XmlRootElement
@CsvRecord(separator = ",",crlf="WINDOWS",generateHeaderColumns=false)
public class Result implements Serializable{
@DataField(pos = 1)
private String firstName;
@DataField(pos = 2)
private String lastName;
@DataField(pos = 3)
private String rollNo;
@DataField(pos = 4)
private String result;
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getRollNo() {
return rollNo;
public void setRollNo(String rollNo) {
this.rollNo = rollNo;
public String getResult() {
return result;
public void setResult(String result) {
this.result = result;
My CAMEL Route file looks like
<bean id="bindyDataformat"
class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
<constructor-arg value="com.poc.camel.csv.java.bindy" />
</bean>
<bean id="csv" class="com.poc.camel.csv.java.bindy.HandleOrderBean" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<jaxb id="myJaxb" prettyPrint="true"
contextPath="com.poc.camel.csv.java.bindy" />
</dataFormats>
<route streamCache="true">
<from uri="file://C:/Users/Mathews/Desktop/in" />
<unmarshal ref="bindyDataformat" />
<to uri="bean:csv" />
</route>
<route>
<from uri="seda:queue:in" />
<to uri="log:reached route 2"/>
<marshal ref="myJaxb" />
<to uri="file://C:/Users/Mathews/Desktop/out" />
</route>
</camelContext>
</beans>
And my Java Processor looks like follows
package com.poc.camel.csv.java.bindy;
import java.util.ArrayList;
import java.util.List;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultProducerTemplate;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
public class HandleOrderBean implements Processor {
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
CamelContext context = new DefaultCamelContext();
ProducerTemplate template = context.createProducerTemplate();
Result result = new Result();
List<Result> listofResults = new ArrayList<Result>();
listofResults = exchange.getIn().getBody(ArrayList.class);
for (int i = 0; i < listofResults.size(); i++) {
result = listofResults.get(i);
// send to a specific queue
template.sendBody("seda:queue:in", result);
But I get following error
[pache.camel.spring.Main.main()] DefaultStreamCachingStrategy INFO
StreamCaching in use with spool directory:
C:\Users\Mathews\AppData\Local\Temp\camel\camel-tmp-127025a0-28cb-44a3-9b80-be5cc749ee46
and rules: [Spool > 128K body size]
[pache.camel.spring.Main.main()] JaxbDataFormat INFO
Creating JAXBContext with contextPath: com.poc.camel.csv.java.bindy and
ApplicationContextClassLoader: java.net.URLClassLoader [ at ] 90b96e
[pache.camel.spring.Main.main()] SpringCamelContext INFO Route:
route1 started and consuming from:
Endpoint[file://C:/Users/Mathews/Desktop/in]
[pache.camel.spring.Main.main()] SpringCamelContext INFO Route:
route2 started and consuming from: Endpoint[seda://queue:in]
[pache.camel.spring.Main.main()] SpringCamelContext INFO Total
2 routes, of which 2 is started.
[pache.camel.spring.Main.main()] SpringCamelContext INFO Apache
Camel 2.12.2 (CamelContext: camel-1) started in 1.331 seconds
[://C:/Users/Mathews/Desktop/in] DefaultErrorHandler ERROR Failed
delivery for (MessageId: ID-REJI-PC-49519-1396698959426-0-1 on ExchangeId:
ID-REJI-PC-49519-1396698959426-0-2). Exhausted after delivery attempt: 1
caught: java.lang.ClassCastException: java.util.HashMap cannot be cast to
com.poc.camel.csv.java.bindy.Result
Message History
I was creating a POC which reads a CSV file with following content
*reji,mathews,2681,pass
jack,rose,261,fail
The class defined is as follows
package com.poc.camel.csv.java.bindy;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
@XmlRootElement
@CsvRecord(separator = ",",crlf="WINDOWS",generateHeaderColumns=false)
public class Result implements Serializable{
@DataField(pos = 1)
private String firstName;
@DataField(pos = 2)
private String lastName;
@DataField(pos = 3)
private String rollNo;
@DataField(pos = 4)
private String result;
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getRollNo() {
return rollNo;
public void setRollNo(String rollNo) {
this.rollNo = rollNo;
public String getResult() {
return result;
public void setResult(String result) {
this.result = result;
My CAMEL Route file looks like
<bean id="bindyDataformat"
class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
<constructor-arg value="com.poc.camel.csv.java.bindy" />
</bean>
<bean id="csv" class="com.poc.camel.csv.java.bindy.HandleOrderBean" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<jaxb id="myJaxb" prettyPrint="true"
contextPath="com.poc.camel.csv.java.bindy" />
</dataFormats>
<route streamCache="true">
<from uri="file://C:/Users/Mathews/Desktop/in" />
<unmarshal ref="bindyDataformat" />
<to uri="bean:csv" />
</route>
<route>
<from uri="seda:queue:in" />
<to uri="log:reached route 2"/>
<marshal ref="myJaxb" />
<to uri="file://C:/Users/Mathews/Desktop/out" />
</route>
</camelContext>
</beans>
And my Java Processor looks like follows
package com.poc.camel.csv.java.bindy;
import java.util.ArrayList;
import java.util.List;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultProducerTemplate;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
public class HandleOrderBean implements Processor {
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
CamelContext context = new DefaultCamelContext();
ProducerTemplate template = context.createProducerTemplate();
Result result = new Result();
List<Result> listofResults = new ArrayList<Result>();
listofResults = exchange.getIn().getBody(ArrayList.class);
for (int i = 0; i < listofResults.size(); i++) {
result = listofResults.get(i);
// send to a specific queue
template.sendBody("seda:queue:in", result);
But I get following error
[pache.camel.spring.Main.main()] DefaultStreamCachingStrategy INFO
StreamCaching in use with spool directory:
C:\Users\Mathews\AppData\Local\Temp\camel\camel-tmp-127025a0-28cb-44a3-9b80-be5cc749ee46
and rules: [Spool > 128K body size]
[pache.camel.spring.Main.main()] JaxbDataFormat INFO
Creating JAXBContext with contextPath: com.poc.camel.csv.java.bindy and
ApplicationContextClassLoader: java.net.URLClassLoader [ at ] 90b96e
[pache.camel.spring.Main.main()] SpringCamelContext INFO Route:
route1 started and consuming from:
Endpoint[file://C:/Users/Mathews/Desktop/in]
[pache.camel.spring.Main.main()] SpringCamelContext INFO Route:
route2 started and consuming from: Endpoint[seda://queue:in]
[pache.camel.spring.Main.main()] SpringCamelContext INFO Total
2 routes, of which 2 is started.
[pache.camel.spring.Main.main()] SpringCamelContext INFO Apache
Camel 2.12.2 (CamelContext: camel-1) started in 1.331 seconds
[://C:/Users/Mathews/Desktop/in] DefaultErrorHandler ERROR Failed
delivery for (MessageId: ID-REJI-PC-49519-1396698959426-0-1 on ExchangeId:
ID-REJI-PC-49519-1396698959426-0-2). Exhausted after delivery attempt: 1
caught: java.lang.ClassCastException: java.util.HashMap cannot be cast to
com.poc.camel.csv.java.bindy.Result
Message History