Search in sources :

Example 86 with Route

use of org.apache.camel.Route in project Activiti by Activiti.

the class SimpleProcessTest method tearDown.

public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
Also used : Route(org.apache.camel.Route)

Example 87 with Route

use of org.apache.camel.Route in project Activiti by Activiti.

the class SimpleSpringProcessTest method tearDown.

public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
Also used : Route(org.apache.camel.Route)

Example 88 with Route

use of org.apache.camel.Route in project Activiti by Activiti.

the class TestReturnValueFromActiviti method tearDown.

public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
Also used : Route(org.apache.camel.Route)

Example 89 with Route

use of org.apache.camel.Route in project Activiti by Activiti.

the class CamelVariableTransferTest method tearDown.

public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
Also used : Route(org.apache.camel.Route)

Example 90 with Route

use of org.apache.camel.Route in project ddf by codice.

the class HttpProxyCamelHttpTransportServlet method doService.

@Override
protected void doService(HttpServletRequest oldRequest, HttpServletResponse response) throws ServletException, IOException {
    //Wrap request and clean the query String
    HttpProxyWrappedCleanRequest request = new HttpProxyWrappedCleanRequest(oldRequest);
    log.trace("Service: {}", request);
    // Is there a consumer registered for the request.
    HttpConsumer consumer = resolve(request);
    if (consumer == null) {
        String path = request.getPathInfo();
        log.trace("Service Request Path = {}", path);
        String endpointName = getEndpointNameFromPath(path);
        log.trace("Endpoint Name = {}", endpointName);
        Route route = camelContext.getRoute(endpointName);
        try {
            if (route != null) {
                connect((HttpConsumer) route.getConsumer());
            }
        } catch (Exception e) {
            log.debug("Exception while creating consumer", e);
        }
        consumer = resolve(request);
    }
    if (consumer == null) {
        log.debug("No consumer to service request {}", request);
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
    }
    // are we suspended?
    if (consumer.getEndpoint().isSuspended()) {
        log.debug("Consumer suspended, cannot service request {}", request);
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        return;
    }
    if (consumer.getEndpoint().getHttpMethodRestrict() != null && !consumer.getEndpoint().getHttpMethodRestrict().equals(request.getMethod())) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }
    if ("TRACE".equals(request.getMethod()) && !consumer.getEndpoint().isTraceEnabled()) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }
    // create exchange and set data on it
    Exchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
    if (consumer.getEndpoint().isBridgeEndpoint()) {
        exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
    }
    if (consumer.getEndpoint().isDisableStreamCache()) {
        exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
    }
    // we override the classloader before building the HttpMessage just in case the binding
    // does some class resolution
    ClassLoader oldTccl = overrideTccl(exchange);
    HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
    exchange.setIn(new HttpMessage(exchange, request, response));
    // set context path as header
    String contextPath = consumer.getEndpoint().getPath();
    exchange.getIn().setHeader("CamelServletContextPath", contextPath);
    String httpPath = (String) exchange.getIn().getHeader(Exchange.HTTP_PATH);
    // here we just remove the CamelServletContextPath part from the HTTP_PATH
    if (contextPath != null && httpPath.startsWith(contextPath)) {
        exchange.getIn().setHeader(Exchange.HTTP_PATH, httpPath.substring(contextPath.length()));
    }
    // we want to handle the UoW
    try {
        consumer.createUoW(exchange);
    } catch (Exception e) {
        log.debug("Error processing request", e);
        throw new ServletException(e);
    }
    try {
        if (log.isTraceEnabled()) {
            log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
        }
        // process the exchange
        consumer.getProcessor().process(exchange);
    } catch (Exception e) {
        exchange.setException(e);
    }
    try {
        // now lets output to the response
        if (log.isTraceEnabled()) {
            log.trace("Writing response for exchangeId: {}", exchange.getExchangeId());
        }
        Integer bs = consumer.getEndpoint().getResponseBufferSize();
        if (bs != null) {
            log.trace("Using response buffer size: {}", bs);
            response.setBufferSize(bs);
        }
        consumer.getBinding().writeResponse(exchange, response);
    } catch (IOException e) {
        log.debug("Error processing request", e);
        throw e;
    } catch (Exception e) {
        log.debug("Error processing request", e);
        throw new ServletException(e);
    } finally {
        consumer.doneUoW(exchange);
        restoreTccl(exchange, oldTccl);
    }
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) HttpConsumer(org.apache.camel.http.common.HttpConsumer) HttpMessage(org.apache.camel.http.common.HttpMessage) Route(org.apache.camel.Route) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

Route (org.apache.camel.Route)90 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)27 Endpoint (org.apache.camel.Endpoint)24 Channel (org.apache.camel.Channel)17 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)15 Processor (org.apache.camel.Processor)13 ArrayList (java.util.ArrayList)12 SendProcessor (org.apache.camel.processor.SendProcessor)11 CamelContext (org.apache.camel.CamelContext)10 ShutdownRoute (org.apache.camel.ShutdownRoute)8 FilterProcessor (org.apache.camel.processor.FilterProcessor)7 RoutePolicy (org.apache.camel.spi.RoutePolicy)6 HashMap (java.util.HashMap)5 Service (org.apache.camel.Service)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 DelegateProcessor (org.apache.camel.DelegateProcessor)4 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4