Search in sources :

Example 6 with EventDrivenConsumerRoute

use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.

the class StreamResequencerTest method doTestStreamResequencerType.

protected void doTestStreamResequencerType() throws Exception {
    List<Route> list = getRouteList(createRouteBuilder());
    assertEquals("Number of routes created: " + list, 1, list.size());
    Route route = list.get(0);
    EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
    Channel channel = unwrapChannel(consumerRoute.getProcessor());
    assertIsInstanceOf(DefaultErrorHandler.class, channel.getErrorHandler());
    assertIsInstanceOf(StreamResequencer.class, channel.getNextProcessor());
}
Also used : Channel(org.apache.camel.Channel) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 7 with EventDrivenConsumerRoute

use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.

the class AbstractTransactionTest method getConditionalExceptionProcessor.

/**
     * By default routes should be wrapped in the {@link DeadLetterChannel} so
     * lets unwrap that and return the actual processor
     */
protected ConditionalExceptionProcessor getConditionalExceptionProcessor(Route route) {
    // the following is very specific (and brittle) and is not generally
    // useful outside these transaction tests (nor intended to be).
    EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
    Processor processor = findProcessorByClass(consumerRoute.getProcessor(), ConditionalExceptionProcessor.class);
    return assertIsInstanceOf(ConditionalExceptionProcessor.class, processor);
}
Also used : DelegateProcessor(org.apache.camel.DelegateProcessor) Processor(org.apache.camel.Processor) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 8 with EventDrivenConsumerRoute

use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.

the class ErrorHandlerTest method testEndpointConfiguration.

public void testEndpointConfiguration() throws Exception {
    SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
    List<Route> list = context.getRoutes();
    assertEquals("Number routes created" + list, 2, list.size());
    for (Route route : list) {
        EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
        Channel channel = unwrapChannel(consumerRoute.getProcessor());
        DeadLetterChannel deadLetterChannel = assertIsInstanceOf(DeadLetterChannel.class, channel.getErrorHandler());
        RedeliveryPolicy redeliveryPolicy = deadLetterChannel.getRedeliveryPolicy();
        assertEquals("getMaximumRedeliveries()", 1, redeliveryPolicy.getMaximumRedeliveries());
        assertEquals("isUseExponentialBackOff()", true, redeliveryPolicy.isUseExponentialBackOff());
    }
}
Also used : DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) Channel(org.apache.camel.Channel) DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) RedeliveryPolicy(org.apache.camel.processor.RedeliveryPolicy) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 9 with EventDrivenConsumerRoute

use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.

the class CamelContextFactoryBeanTest method testXMLRouteLoading.

public void testXMLRouteLoading() throws Exception {
    applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
    CamelContext context = applicationContext.getBean("camel2", CamelContext.class);
    assertNotNull("No context found!", context);
    List<Route> routes = context.getRoutes();
    LOG.debug("Found routes: " + routes);
    assertNotNull("Should have found some routes", routes);
    assertEquals("One Route should be found", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
        Processor processor = consumerRoute.getProcessor();
        assertNotNull(processor);
        assertEndpointUri(key, "seda://test.c");
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) Processor(org.apache.camel.Processor) Endpoint(org.apache.camel.Endpoint) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 10 with EventDrivenConsumerRoute

use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.

the class DefaultManagementLifecycleStrategy method onRoutesAdd.

public void onRoutesAdd(Collection<Route> routes) {
    for (Route route : routes) {
        // enabled, then enlist the route as a known route
        if (getCamelContext().getStatus().isStarting() || getManagementStrategy().getManagementAgent().getRegisterAlways() || getManagementStrategy().getManagementAgent().getRegisterNewRoutes()) {
            // register as known route id
            knowRouteIds.add(route.getId());
        }
        if (!shouldRegister(route, route)) {
            // avoid registering if not needed, skip to next route
            continue;
        }
        Object mr = getManagementObjectStrategy().getManagedObjectForRoute(camelContext, route);
        // skip already managed routes, for example if the route has been restarted
        if (getManagementStrategy().isManaged(mr, null)) {
            LOG.trace("The route is already managed: {}", route);
            continue;
        }
        // and set me as the counter
        if (route instanceof EventDrivenConsumerRoute) {
            EventDrivenConsumerRoute edcr = (EventDrivenConsumerRoute) route;
            Processor processor = edcr.getProcessor();
            if (processor instanceof CamelInternalProcessor && mr instanceof ManagedRoute) {
                CamelInternalProcessor internal = (CamelInternalProcessor) processor;
                ManagedRoute routeMBean = (ManagedRoute) mr;
                CamelInternalProcessor.InstrumentationAdvice task = internal.getAdvice(CamelInternalProcessor.InstrumentationAdvice.class);
                if (task != null) {
                    // we need to wrap the counter with the camel context so we get stats updated on the context as well
                    if (camelContextMBean != null) {
                        CompositePerformanceCounter wrapper = new CompositePerformanceCounter(routeMBean, camelContextMBean);
                        task.setCounter(wrapper);
                    } else {
                        task.setCounter(routeMBean);
                    }
                }
            }
        }
        try {
            manageObject(mr);
        } catch (JMException e) {
            LOG.warn("Could not register Route MBean", e);
        } catch (Exception e) {
            LOG.warn("Could not create Route MBean", e);
        }
    }
}
Also used : CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) Processor(org.apache.camel.Processor) ManagedRoute(org.apache.camel.management.mbean.ManagedRoute) JMException(javax.management.JMException) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) ManagedRoute(org.apache.camel.management.mbean.ManagedRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) MalformedObjectNameException(javax.management.MalformedObjectNameException) JMException(javax.management.JMException) VetoCamelContextStartException(org.apache.camel.VetoCamelContextStartException)

Aggregations

EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)23 Route (org.apache.camel.Route)21 Channel (org.apache.camel.Channel)17 Endpoint (org.apache.camel.Endpoint)15 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)15 Processor (org.apache.camel.Processor)13 SendProcessor (org.apache.camel.processor.SendProcessor)12 FilterProcessor (org.apache.camel.processor.FilterProcessor)8 DelegateProcessor (org.apache.camel.DelegateProcessor)6 ChoiceProcessor (org.apache.camel.processor.ChoiceProcessor)5 EvaluateExpressionProcessor (org.apache.camel.processor.EvaluateExpressionProcessor)5 MulticastProcessor (org.apache.camel.processor.MulticastProcessor)5 ThreadsProcessor (org.apache.camel.processor.ThreadsProcessor)5 Pipeline (org.apache.camel.processor.Pipeline)3 RedeliveryPolicy (org.apache.camel.processor.RedeliveryPolicy)3 ArrayList (java.util.ArrayList)2 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)2 JMException (javax.management.JMException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 CamelContext (org.apache.camel.CamelContext)1