Thanks For Reply,
But it gives me null as a output. I am providing a source code for same,
Please suggest me the changes.
public class UnMarshallingTest {
public static void main(String[] args) throws Exception {
DefaultCamelContext context = new DefaultCamelContext();
// append the routes to the context
context.addRoutes(new UnMarshallingTestRoute());
CSVToPerson csvToPerson = new CSVToPerson();
SimpleRegistry reg = new SimpleRegistry();
reg.put("csvToPerson", csvToPerson);
context.setRegistry(reg);
context.start();
ConsumerTemplate ct = context.createConsumerTemplate();
Object data = ct.receiveBody("seda:foo", 5000);
System.out.println("Return Value::::" + data);
Thread.sleep(3000);
context.stop();
}
}
public class UnMarshallingTestRoute extends RouteBuilder {
public void configure() throws Exception {
from("file:/home/viral/Projects/camel/cxfJavaTest/src/data?noop=true")
// .split(body().tokenize("\n")).streaming()
.unmarshal().csv()
.beanRef("csvToPerson", "process").to ("seda:foo") ;
}
}
public class CSVToPerson {
public List<Person> process(List<List> csvRows) {
List<Person> oList = new ArrayList<Person>();
System.out.println("called");
for (List csvRow : csvRows) {
Person person = new Person();
person.setFirstName((String) csvRow.get(0));
person.setLastName((String) csvRow.get(1));
oList.add(person);
// doSomethingTo(person);
System.out.println("++++++++++++++++++++++++++");
System.out.println(person);
System.out.println("++++++++++++++++++++++++++");
}
System.out.println("End");
return oList;
}
}
public class Person {
private String firstName;
private String lastName;
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;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.firstName + "===" + this.lastName;
}
}
Please suggest me the changes
--
View this message in context:
http://camel.465427.n5.nabble.com/CSV-file-tp466057p5769376.html
Sent from the Camel - Users mailing list archive at Nabble.com.