Reputation: 12900
I am starting a project using Apache Camel and would like to add a way to store some information as properties. Most example seem to use Spring and XML, but I'm going the Java DSL way and can't seem to find good examples on how to do this properly.
I created a project from the camel-archetype-java archetype, and have only added Quartz and one route to it so far:
package com.commserv.integration;
import org.apache.camel.builder.RouteBuilder;
public class FilemakerCsvToMailroom extends RouteBuilder {
public void configure() {
from("file:/Volumes/Data-1/Camel?autoCreate=false&startingDirectoryMustExist=true&noop=true&scheduler=quartz2&scheduler.cron=0+*+*+*+*+?&scheduler.triggerId=EveryMinute&scheduler.triggerGroup=FilemakerCsvToMailroom") // every minute
.routeId("FilemakerCsvToMailroom")
.log("FilemakerCsvToMailroom triggered");
}
}
Project code can be viewed at this link.
context
variable, but not sure where that comes from.Upvotes: 1
Views: 1522
Reputation: 745
You can add the properties file to src/main/resources.
You can configure Properties Component with Java like this:
public void configure() {
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:myprop.properties");
getContext().addComponent("properties", pc);
// Will output "result1" every 5 seconds.
from("timer:mytimer?period=5s")
.log("{{dev.endpoint}}");
}
if you have properties file src/main/resources/myprop.properties containing
dev.endpoint = result1
test.endpoint = result2
Note that you can call to getContext() inside RouteBuilder to get the running Camel context.
Upvotes: 1