Search in sources :

Example 16 with Channel

use of org.apache.camel.Channel 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 17 with Channel

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

the class RouteBuilderTest method testSimpleRouteWithHeaderPredicate.

public void testSimpleRouteWithHeaderPredicate() throws Exception {
    List<Route> routes = buildSimpleRouteWithHeaderPredicate();
    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());
        FilterProcessor filterProcessor = assertIsInstanceOf(FilterProcessor.class, channel.getNextProcessor());
        SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, unwrapChannel(filterProcessor).getNextProcessor());
        assertEquals("Endpoint URI", "direct://b", sendProcessor.getDestination().getEndpointUri());
    }
}
Also used : 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) SendProcessor(org.apache.camel.processor.SendProcessor) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 18 with Channel

use of org.apache.camel.Channel 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)

Example 19 with Channel

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

the class RouteBuilderTest method testIdempotentConsumer.

public void testIdempotentConsumer() throws Exception {
    List<Route> routes = buildIdempotentConsumer();
    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());
        IdempotentConsumer idempotentConsumer = assertIsInstanceOf(IdempotentConsumer.class, channel.getNextProcessor());
        assertEquals("messageIdExpression", "header(myMessageId)", idempotentConsumer.getMessageIdExpression().toString());
        assertIsInstanceOf(MemoryIdempotentRepository.class, idempotentConsumer.getIdempotentRepository());
        SendProcessor sendProcessor = assertIsInstanceOf(SendProcessor.class, unwrapChannel(idempotentConsumer.getProcessor()).getNextProcessor());
        assertEquals("Endpoint URI", "direct://b", sendProcessor.getDestination().getEndpointUri());
    }
}
Also used : Endpoint(org.apache.camel.Endpoint) Channel(org.apache.camel.Channel) DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) IdempotentConsumer(org.apache.camel.processor.idempotent.IdempotentConsumer) SendProcessor(org.apache.camel.processor.SendProcessor) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 20 with Channel

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

the class RouteBuilderTest method testSplitter.

public void testSplitter() throws Exception {
    List<Route> routes = buildSplitter();
    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());
        assertIsInstanceOf(Splitter.class, channel.getNextProcessor());
    }
}
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)

Aggregations

Channel (org.apache.camel.Channel)21 Route (org.apache.camel.Route)17 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)17 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)15 Endpoint (org.apache.camel.Endpoint)13 Processor (org.apache.camel.Processor)12 SendProcessor (org.apache.camel.processor.SendProcessor)10 FilterProcessor (org.apache.camel.processor.FilterProcessor)6 ArrayList (java.util.ArrayList)3 DelegateProcessor (org.apache.camel.DelegateProcessor)3 ChoiceProcessor (org.apache.camel.processor.ChoiceProcessor)3 EvaluateExpressionProcessor (org.apache.camel.processor.EvaluateExpressionProcessor)3 MulticastProcessor (org.apache.camel.processor.MulticastProcessor)3 RedeliveryPolicy (org.apache.camel.processor.RedeliveryPolicy)3 ThreadsProcessor (org.apache.camel.processor.ThreadsProcessor)3 Pipeline (org.apache.camel.processor.Pipeline)2 Consumer (org.apache.camel.Consumer)1 NonManagedService (org.apache.camel.NonManagedService)1 Producer (org.apache.camel.Producer)1 Service (org.apache.camel.Service)1