camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Not able to define processor in Camel
Date Thu, 24 Jul 2014 12:28:31 GMT
Hi

<bean id= "jsonProcessor" class="com.validator.parser.JsonParser" />

should be outside <route>

On Thu, Jul 24, 2014 at 2:22 PM, nettome <gsharma84@gmail.com> wrote:
> Hi,
> I'm new to Camel and learning it step by step.
> I have a scenario where i have to process a task in a route. I'm creating a
> XML file and loading the routes from it.
> Below is my xml file -
>
> <routes xmlns="http://camel.apache.org/schema/spring">
> <bean id= "jsonProcessor" class="com.validator.parser.JsonParser" />
>     <route id="fromFile">
>         <from uri="file:/data/inbox"/>
>         <process ref="jsonProcessor" />
>         <to uri="cache:default"/>
>     </route>
> </routes>
>
> Code to load the XML file -
>
> ModelCamelContext context = (ModelCamelContext) new DefaultCamelContext();
>                 RouteBuilder builder = null;
>                 File fileFolder = new
> File("/home/workspace/Validator/src/main/resources/com/validator/routes");
>
>                 // load route from XML and add them to the existing camel context
>                 RoutesDefinition routes;
>
>                 try {
>
>                         for(final File file : fileFolder.listFiles()){
>                                 if(file.isFile()){
>                                         InputStream in = new FileInputStream(file);
>                                         routes = context.loadRoutesDefinition(in);
>                                         context.addRouteDefinitions(routes.getRoutes());
>                                 }
>                         }
>
>                         context.start();
>                         Thread.sleep(4000);
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                 }
>
>
>
>
> JsonParser is a Processor and I want the route to go to the processor. But
> while I'm doing the above I'm getting the following error -
>
> Caused by: java.lang.IllegalArgumentException: registry entry called
> jsonProcessor must be specified on: process[ref:jsonProcessor]
>
>
> there are couple of things I'm missing/not clear over here -
>
> 1. Is my bean definition correct?
> 2. Should I create the camelContext in the XML file or the Java code
> 3. Is my XML structured properly.
>
> Please guide. I'm stuck and not able to find much on the internet.
>
> thanks!
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Not-able-to-define-processor-in-Camel-tp5754376.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message