Search in sources :

Example 96 with RouteDefinition

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;
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition)

Example 97 with RouteDefinition

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;
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition)

Example 98 with RouteDefinition

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);
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition)

Example 99 with RouteDefinition

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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RouteDefinition(org.apache.camel.model.RouteDefinition)

Example 100 with RouteDefinition

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);
}
Also used : FromDefinition(org.apache.camel.model.FromDefinition) RouteDefinition(org.apache.camel.model.RouteDefinition) ServiceStatus(org.apache.camel.ServiceStatus)

Aggregations

RouteDefinition (org.apache.camel.model.RouteDefinition)102 AdviceWithRouteBuilder (org.apache.camel.builder.AdviceWithRouteBuilder)17 RouteBuilder (org.apache.camel.builder.RouteBuilder)17 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 FromDefinition (org.apache.camel.model.FromDefinition)9 HashMap (java.util.HashMap)6 Processor (org.apache.camel.Processor)6 ConnectException (java.net.ConnectException)5 Exchange (org.apache.camel.Exchange)5 ProcessorDefinition (org.apache.camel.model.ProcessorDefinition)5 IOException (java.io.IOException)4 Map (java.util.Map)4 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 ChoiceDefinition (org.apache.camel.model.ChoiceDefinition)4 HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)4 HystrixDefinition (org.apache.camel.model.HystrixDefinition)4 LogDefinition (org.apache.camel.model.LogDefinition)4 ModelCamelContext (org.apache.camel.model.ModelCamelContext)4