hi viral069, What is your use case after retrieve your List outside the camel context ? Because camel can do lot of stuff only with route and component.
but if you really need the List. You can add set/get into CSVToPerson class. but : - You cannot know when the message is fired, and update the List field. - CSVToPerson is singleton, and this pattern MUST not share any object. Greg AUTRIC JBoss Middleware Consultant email : gautric __at__ redhat __dot__ com twitter : @gautric_io Red Hat Global Services Red Hat France SARL sit: http://www.redhat.fr Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex Sent from webmail ----- Mail original ----- De: "viral069" <[email protected]> À: [email protected] Envoyé: Mardi 14 Juillet 2015 13:49:14 Objet: unable to retrieve response from camel context Dear All, I am working on CSV to Object creation Example with the use of Camel. I have create a bean in which i have a method with will do all operation, and that method will return List. My Question is how i am able to get List outside the Camel. Source Code: 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; } } 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(); Thread.sleep(3000); System.out.println("Done"); context.stop(); } } public class UnMarshallingTestRoute extends RouteBuilder { public void configure() throws Exception { from("file:/home/viral/Projects/camel/cxfJavaTest/src/data?noop=true") .unmarshal().csv() .beanRef("csvToPerson", "process"); } } 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; } } I have Only Camel Context Object how i am able to get List from context Object. -- View this message in context: http://camel.465427.n5.nabble.com/unable-to-retrieve-response-from-camel-context-tp5769282.html Sent from the Camel - Users mailing list archive at Nabble.com.
