Search in sources :

Example 31 with Processor

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

the class CxfRsConsumerTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    final Processor testProcessor = new TestProcessor();
    final Processor testProcessor2 = new TestProcessor2();
    final Processor testProcessor3 = new TestProcessor3();
    return new RouteBuilder() {

        public void configure() {
            errorHandler(new NoErrorHandlerBuilder());
            from(CXF_RS_ENDPOINT_URI).process(testProcessor);
            from(CXF_RS_ENDPOINT_URI2).process(testProcessor);
            from(CXF_RS_ENDPOINT_URI3).process(testProcessor);
            from(CXF_RS_ENDPOINT_URI4).process(testProcessor2);
            from(CXF_RS_ENDPOINT_URI5).process(testProcessor3);
        }
    };
}
Also used : Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) NoErrorHandlerBuilder(org.apache.camel.builder.NoErrorHandlerBuilder)

Example 32 with Processor

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

the class DisruptorVmWaitForTaskNewerTest method testInOnly.

public void testInOnly() throws Exception {
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
    Exchange out = template2.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setBody("Hello World");
            exchange.setPattern(ExchangePattern.InOnly);
        }
    });
    // we do not wait for the response so we just get our own input back
    assertEquals("Hello World", out.getIn().getBody());
    assertNull(out.getOut().getBody());
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor)

Example 33 with Processor

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

the class DisruptorUnitOfWorkTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            context.setTracing(true);
            from("direct:start").process(new MyUOWProcessor("A")).to("disruptor:foo");
            from("disruptor:foo").process(new Processor() {

                @Override
                public void process(final Exchange exchange) throws Exception {
                    assertEquals(null, sync);
                }
            }).process(new Processor() {

                @Override
                public void process(final Exchange exchange) throws Exception {
                    lastOne = "processor";
                }
            }).to("mock:result");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 34 with Processor

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

the class DisruptorWaitForTaskAsPropertyTest method testInOut.

@Test
public void testInOut() throws Exception {
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
    final Exchange out = template.send("direct:start", new Processor() {

        @Override
        public void process(final Exchange exchange) throws Exception {
            exchange.getIn().setBody("Hello World");
            exchange.setPattern(ExchangePattern.InOut);
            exchange.setProperty(Exchange.ASYNC_WAIT, WaitForTaskToComplete.IfReplyExpected);
        }
    });
    assertEquals("Bye World", out.getOut().getBody());
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Test(org.junit.Test)

Example 35 with Processor

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

the class DisruptorWaitForTaskCompleteOnCompletionTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            errorHandler(defaultErrorHandler().maximumRedeliveries(3).redeliveryDelay(0));
            from("direct:start").process(new Processor() {

                @Override
                public void process(final Exchange exchange) throws Exception {
                    exchange.addOnCompletion(new SynchronizationAdapter() {

                        @Override
                        public void onDone(final Exchange exchange) {
                            done += "A";
                        }
                    });
                }
            }).to("disruptor:foo?waitForTaskToComplete=Always").process(new Processor() {

                @Override
                public void process(final Exchange exchange) throws Exception {
                    done += "B";
                }
            }).to("mock:result");
            from("disruptor:foo").errorHandler(noErrorHandler()).process(new Processor() {

                @Override
                public void process(final Exchange exchange) throws Exception {
                    done = done + "C";
                }
            }).throwException(new IllegalArgumentException("Forced"));
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) SynchronizationAdapter(org.apache.camel.support.SynchronizationAdapter)

Aggregations

Processor (org.apache.camel.Processor)1467 Exchange (org.apache.camel.Exchange)1368 Test (org.junit.Test)634 RouteBuilder (org.apache.camel.builder.RouteBuilder)543 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)164 Message (org.apache.camel.Message)119 ArrayList (java.util.ArrayList)65 HashMap (java.util.HashMap)64 IOException (java.io.IOException)55 CamelExecutionException (org.apache.camel.CamelExecutionException)52 Endpoint (org.apache.camel.Endpoint)46 Map (java.util.Map)45 File (java.io.File)38 List (java.util.List)34 Producer (org.apache.camel.Producer)33 DefaultExchange (org.apache.camel.impl.DefaultExchange)29 SendProcessor (org.apache.camel.processor.SendProcessor)26 AggregationStrategy (org.apache.camel.processor.aggregate.AggregationStrategy)26 CountDownLatch (java.util.concurrent.CountDownLatch)24 Expression (org.apache.camel.Expression)24