Search in sources :

Example 41 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class CamelCommandsFacade method getCamelContextForRoute.

private String getCamelContextForRoute(String routeId) throws Exception {
    ArrayList<String> contextNames = new ArrayList<String>();
    for (CamelContext camelContext : camelController.getLocalCamelContexts()) {
        for (Route route : camelContext.getRoutes()) {
            if (routeId.equals(route.getId())) {
                contextNames.add(camelContext.getName());
                break;
            }
        }
    }
    if (contextNames.size() != 1) {
        StringBuffer error = new StringBuffer();
        error.append("Cannot infer CamelContext. Please provide manually.");
        if (contextNames.size() > 1) {
            error.append(" Contexts : " + contextNames.toString());
        }
        throw new org.crsh.cli.impl.SyntaxException(error.toString());
    }
    return contextNames.get(0);
}
Also used : CamelContext(org.apache.camel.CamelContext) ArrayList(java.util.ArrayList) Route(org.apache.camel.Route)

Example 42 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class CamelControllerImpl method getCamelContexts.

public List<Map<String, String>> getCamelContexts() throws Exception {
    List<Map<String, String>> answer = new ArrayList<Map<String, String>>();
    List<CamelContext> camelContexts = getLocalCamelContexts();
    for (CamelContext camelContext : camelContexts) {
        Map<String, String> row = new LinkedHashMap<String, String>();
        row.put("name", camelContext.getName());
        row.put("state", camelContext.getStatus().name());
        row.put("uptime", camelContext.getUptime());
        if (camelContext.getManagedCamelContext() != null) {
            row.put("exchangesTotal", "" + camelContext.getManagedCamelContext().getExchangesTotal());
            row.put("exchangesInflight", "" + camelContext.getManagedCamelContext().getExchangesInflight());
            row.put("exchangesFailed", "" + camelContext.getManagedCamelContext().getExchangesFailed());
        } else {
            row.put("exchangesTotal", "0");
            row.put("exchangesInflight", "0");
            row.put("exchangesFailed", "0");
        }
        answer.add(row);
    }
    return answer;
}
Also used : CamelContext(org.apache.camel.CamelContext) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 43 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class BaseNettyTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addComponent("properties", new PropertiesComponent("ref:prop"));
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 44 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class NagiosEventNotifierTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    NagiosEventNotifier notifier = new NagiosEventNotifier(nagiosPassiveCheckSender);
    notifier.getConfiguration().setHost("localhost");
    notifier.getConfiguration().setPort(25669);
    notifier.getConfiguration().setPassword("password");
    CamelContext context = super.createCamelContext();
    context.getManagementStrategy().addEventNotifier(notifier);
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext)

Example 45 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class BaseNettyTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addComponent("properties", new PropertiesComponent("ref:prop"));
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Aggregations

CamelContext (org.apache.camel.CamelContext)1478 Test (org.junit.Test)691 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)684 RouteBuilder (org.apache.camel.builder.RouteBuilder)448 ProducerTemplate (org.apache.camel.ProducerTemplate)434 ConnectionFactory (javax.jms.ConnectionFactory)220 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)210 Exchange (org.apache.camel.Exchange)109 HashMap (java.util.HashMap)93 Endpoint (org.apache.camel.Endpoint)52 DefaultExchange (org.apache.camel.impl.DefaultExchange)50 IOException (java.io.IOException)46 Map (java.util.Map)45 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)44 CountDownLatch (java.util.concurrent.CountDownLatch)42 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)42 ArrayList (java.util.ArrayList)41 Processor (org.apache.camel.Processor)40 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)37 CamelExecutionException (org.apache.camel.CamelExecutionException)33