use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class RouteBuilder method from.
/**
* Creates a new route from the given URI input
*
* @param uri the from uri
* @return the builder
*/
public RouteDefinition from(String uri) {
getRouteCollection().setCamelContext(getContext());
RouteDefinition answer = getRouteCollection().from(uri);
configureRoute(answer);
return answer;
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class RouteBuilder method from.
/**
* Creates a new route from the given endpoint
*
* @param endpoints the from endpoints
* @return the builder
*/
public RouteDefinition from(Endpoint... endpoints) {
getRouteCollection().setCamelContext(getContext());
RouteDefinition answer = getRouteCollection().from(endpoints);
configureRoute(answer);
return answer;
}
use of org.apache.camel.model.RouteDefinition in project ddf by codice.
the class ContentDirectoryMonitorTest method testRouteCreationWithGivenCopyStatus.
private void testRouteCreationWithGivenCopyStatus(String processingMechanism) throws Exception {
submitConfigOptions(monitor, monitoredDirectoryPath, processingMechanism);
assertThat("The content directory monitor should only have one route definition", monitor.getRouteDefinitions(), hasSize(1));
RouteDefinition routeDefinition = monitor.getRouteDefinitions().get(0);
verifyRoute(routeDefinition, monitoredDirectoryPath, processingMechanism);
}
use of org.apache.camel.model.RouteDefinition in project ddf by codice.
the class ContentDirectoryMonitor method createRouteBuilder.
private RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
StringBuilder stringBuilder = new StringBuilder();
// Configure the camel route to ignore changing files (larger files that are in the process of being copied)
// Set the readLockTimeout to 2 * readLockIntervalMilliseconds
// Set the readLockCheckInterval to check every readLockIntervalMilliseconds
stringBuilder.append("file:" + monitoredDirectory);
stringBuilder.append("?recursive=true");
stringBuilder.append("&moveFailed=.errors");
/* ReadLock Configuration */
stringBuilder.append("&readLockMinLength=1");
stringBuilder.append("&readLock=changed");
stringBuilder.append("&readLockTimeout=" + (2 * readLockIntervalMilliseconds));
stringBuilder.append("&readLockCheckInterval=" + readLockIntervalMilliseconds);
/* File Exclusions */
String exclusions = getBlackListAsRegex();
if (StringUtils.isNotBlank(exclusions)) {
stringBuilder.append("&exclude=" + exclusions);
}
switch(processingMechanism) {
case DELETE:
stringBuilder.append("&delete=true");
break;
case MOVE:
stringBuilder.append("&move=.ingested");
break;
case IN_PLACE:
stringBuilder = new StringBuilder("durable:" + monitoredDirectory);
break;
}
LOGGER.trace("inbox = {}", stringBuilder.toString());
RouteDefinition routeDefinition = from(stringBuilder.toString());
if (attributeOverrides != null) {
routeDefinition.setHeader(Constants.ATTRIBUTE_OVERRIDES_KEY).constant(attributeOverrides);
}
if (IN_PLACE.equals(processingMechanism)) {
routeDefinition.setHeader(Constants.STORE_REFERENCE_KEY, simple(String.valueOf(IN_PLACE.equals(processingMechanism)), Boolean.class));
}
LOGGER.trace("About to process scheme content:framework");
routeDefinition.threads(numThreads).process(systemSubjectBinder).to("content:framework");
}
};
}
use of org.apache.camel.model.RouteDefinition in project ddf by codice.
the class ContentDirectoryMonitor method dumpCamelContext.
private void dumpCamelContext(String msg) {
LOGGER.debug("\n\n*************** START: {} *****************", msg);
List<RouteDefinition> routeDefinitions = camelContext.getRouteDefinitions();
if (routeDefinitions != null) {
LOGGER.debug("Number of routes = {}", routeDefinitions.size());
for (RouteDefinition routeDef : routeDefinitions) {
String routeId = routeDef.getId();
LOGGER.debug("route ID = {}", routeId);
List<FromDefinition> routeInputs = routeDef.getInputs();
if (routeInputs.isEmpty()) {
LOGGER.debug("routeInputs are EMPTY");
} else {
for (FromDefinition fromDef : routeInputs) {
LOGGER.debug("route input's URI = {}", fromDef.getUri());
}
}
ServiceStatus routeStatus = camelContext.getRouteStatus(routeId);
if (routeStatus != null) {
LOGGER.debug("Route ID {} is started = {}", routeId, routeStatus.isStarted());
} else {
LOGGER.debug("routeStatus is NULL for routeId = {}", routeId);
}
}
}
LOGGER.debug("*************** END: {} *****************\n\n", msg);
}
Aggregations