nettome
2014-07-24 12:22:46 UTC
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!
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!