Search in sources :

Example 6 with Pipeline

use of org.apache.camel.processor.Pipeline in project camel by apache.

the class RouteBuilderTest method testThreads.

public void testThreads() throws Exception {
    List<Route> routes = buildThreads();
    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());
        Pipeline line = assertIsInstanceOf(Pipeline.class, channel.getNextProcessor());
        Iterator<?> it = line.getProcessors().iterator();
        assertIsInstanceOf(ThreadsProcessor.class, it.next());
        // output should be wrapped in a pipeline
        Pipeline threadsLine = assertIsInstanceOf(Pipeline.class, it.next());
        Iterator<Processor> it2 = threadsLine.getProcessors().iterator();
        assertIsInstanceOf(SendProcessor.class, unwrapChannel(it2.next()).getNextProcessor());
        assertIsInstanceOf(SendProcessor.class, unwrapChannel(it2.next()).getNextProcessor());
    }
}
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) 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) Pipeline(org.apache.camel.processor.Pipeline)

Example 7 with Pipeline

use of org.apache.camel.processor.Pipeline in project camel by apache.

the class RouteBuilderTest method testRouteDynamicReceipentList.

public void testRouteDynamicReceipentList() throws Exception {
    List<Route> routes = buildDynamicRecipientList();
    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());
        Pipeline line = assertIsInstanceOf(Pipeline.class, channel.getNextProcessor());
        Iterator<?> it = line.getProcessors().iterator();
        // EvaluateExpressionProcessor should be wrapped in error handler
        Object first = it.next();
        first = assertIsInstanceOf(DeadLetterChannel.class, first).getOutput();
        assertIsInstanceOf(EvaluateExpressionProcessor.class, first);
        // and the second should NOT be wrapped in error handler
        Object second = it.next();
        assertIsInstanceOf(RecipientList.class, second);
    }
}
Also used : Endpoint(org.apache.camel.Endpoint) 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) Pipeline(org.apache.camel.processor.Pipeline)

Aggregations

Pipeline (org.apache.camel.processor.Pipeline)7 Processor (org.apache.camel.Processor)6 ArrayList (java.util.ArrayList)4 ThreadsProcessor (org.apache.camel.processor.ThreadsProcessor)4 DelegateProcessor (org.apache.camel.DelegateProcessor)3 Endpoint (org.apache.camel.Endpoint)3 Route (org.apache.camel.Route)3 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)3 ChoiceProcessor (org.apache.camel.processor.ChoiceProcessor)3 EvaluateExpressionProcessor (org.apache.camel.processor.EvaluateExpressionProcessor)3 FilterProcessor (org.apache.camel.processor.FilterProcessor)3 MulticastProcessor (org.apache.camel.processor.MulticastProcessor)3 SendProcessor (org.apache.camel.processor.SendProcessor)3 ExecutorService (java.util.concurrent.ExecutorService)2 Channel (org.apache.camel.Channel)2 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)2 RecipientList (org.apache.camel.processor.RecipientList)2 Iterator (java.util.Iterator)1 List (java.util.List)1 CamelContext (org.apache.camel.CamelContext)1