Search in sources :

Example 1 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 2 with EventDrivenConsumerRoute

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

the class DefaultErrorHandlerTest method testRoute.

public void testRoute() {
    Route route = context.getRoutes().get(0);
    EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
    Processor processor = unwrap(consumerRoute.getProcessor());
    Pipeline pipeline = assertIsInstanceOf(Pipeline.class, processor);
    // there should be a default error handler in front of each processor in this pipeline
    for (Processor child : pipeline.getProcessors()) {
        Channel channel = assertIsInstanceOf(Channel.class, child);
        assertNotNull("There should be an error handler", channel.getErrorHandler());
        assertIsInstanceOf(DefaultErrorHandler.class, channel.getErrorHandler());
    }
}
Also used : Processor(org.apache.camel.Processor) Channel(org.apache.camel.Channel) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 3 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 4 with EventDrivenConsumerRoute

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

the class RouteBuilderTest method testRouteWithInterceptor.

public void testRouteWithInterceptor() throws Exception {
    List<Route> routes = buildRouteWithInterceptor();
    log.debug("Created routes: " + routes);
    assertEquals("Number routes created", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        assertEquals("From endpoint", "direct://a", key.getEndpointUri());
        EventDrivenConsumerRoute consumer = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
        Pipeline line = assertIsInstanceOf(Pipeline.class, unwrap(consumer.getProcessor()));
        assertEquals(3, line.getProcessors().size());
        // last should be our seda
        List<Processor> processors = new ArrayList<Processor>(line.getProcessors());
        Processor sendTo = assertIsInstanceOf(SendProcessor.class, unwrapChannel(processors.get(2)).getNextProcessor());
        assertSendTo(sendTo, "direct://d");
    }
}
Also used : DelegateProcessor(org.apache.camel.DelegateProcessor) Processor(org.apache.camel.Processor) MulticastProcessor(org.apache.camel.processor.MulticastProcessor) FilterProcessor(org.apache.camel.processor.FilterProcessor) EvaluateExpressionProcessor(org.apache.camel.processor.EvaluateExpressionProcessor) ThreadsProcessor(org.apache.camel.processor.ThreadsProcessor) SendProcessor(org.apache.camel.processor.SendProcessor) ChoiceProcessor(org.apache.camel.processor.ChoiceProcessor) Endpoint(org.apache.camel.Endpoint) ArrayList(java.util.ArrayList) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Pipeline(org.apache.camel.processor.Pipeline)

Example 5 with EventDrivenConsumerRoute

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

the class RouteBuilderTest method testSimpleRouteWithChoice.

public void testSimpleRouteWithChoice() throws Exception {
    List<Route> routes = buildSimpleRouteWithChoice();
    log.debug("Created routes: " + routes);
    assertEquals("Number routes created", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        assertEquals("From endpoint", "direct://a", key.getEndpointUri());
        EventDrivenConsumerRoute consumer = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
        Channel channel = unwrapChannel(consumer.getProcessor());
        ChoiceProcessor choiceProcessor = assertIsInstanceOf(ChoiceProcessor.class, channel.getNextProcessor());
        List<FilterProcessor> filters = choiceProcessor.getFilters();
        assertEquals("Should be two when clauses", 2, filters.size());
        Processor filter1 = filters.get(0);
        assertSendTo(unwrapChannel(((FilterProcessor) filter1).getProcessor()).getNextProcessor(), "direct://b");
        Processor filter2 = filters.get(1);
        assertSendTo(unwrapChannel(((FilterProcessor) filter2).getProcessor()).getNextProcessor(), "direct://c");
        assertSendTo(unwrapChannel(choiceProcessor.getOtherwise()).getNextProcessor(), "direct://d");
    }
}
Also used : DelegateProcessor(org.apache.camel.DelegateProcessor) Processor(org.apache.camel.Processor) MulticastProcessor(org.apache.camel.processor.MulticastProcessor) FilterProcessor(org.apache.camel.processor.FilterProcessor) EvaluateExpressionProcessor(org.apache.camel.processor.EvaluateExpressionProcessor) ThreadsProcessor(org.apache.camel.processor.ThreadsProcessor) SendProcessor(org.apache.camel.processor.SendProcessor) ChoiceProcessor(org.apache.camel.processor.ChoiceProcessor) Endpoint(org.apache.camel.Endpoint) FilterProcessor(org.apache.camel.processor.FilterProcessor) Channel(org.apache.camel.Channel) DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) ChoiceProcessor(org.apache.camel.processor.ChoiceProcessor)

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