Search in sources :

Example 11 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class MultiCamelContextTest method configureCamelContexts.

@Test
@InSequence(2)
public void configureCamelContexts() throws Exception {
    secondCamelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() {
            from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
        }
    });
    secondCamelContext.startAllRoutes();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 12 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class MultiContextPropertyInjectTest method configureCamelContexts.

@Test
@InSequence(1)
public void configureCamelContexts() throws Exception {
    defaultCamelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() {
            from("direct:in").bean(PropertyInjectBean.class).to("mock:out");
        }
    });
    firstCamelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() {
            from("direct:in").bean(FirstCamelContextPropertyInjectBean.class).to("mock:out");
        }
    });
    secondCamelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() {
            from("direct:in").bean(SecondCamelContextPropertyInjectBean.class).to("mock:out");
        }
    });
    secondCamelContext.startAllRoutes();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 13 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class SslContextParametersCometdProducerConsumerTest method createRouteBuilder.

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

        @Override
        public void configure() throws Exception {
            KeyStoreParameters ksp = new KeyStoreParameters();
            ksp.setResource("jsse/localhost.ks");
            ksp.setPassword("changeit");
            KeyManagersParameters kmp = new KeyManagersParameters();
            kmp.setKeyPassword("changeit");
            kmp.setKeyStore(ksp);
            TrustManagersParameters tmp = new TrustManagersParameters();
            tmp.setKeyStore(ksp);
            SSLContextParameters sslContextParameters = new SSLContextParameters();
            sslContextParameters.setKeyManagers(kmp);
            sslContextParameters.setTrustManagers(tmp);
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslContextParameters(sslContextParameters);
            from("direct:input").to(uri);
            from(uri).to("mock:test");
        }
    };
}
Also used : KeyManagersParameters(org.apache.camel.util.jsse.KeyManagersParameters) RouteBuilder(org.apache.camel.builder.RouteBuilder) TrustManagersParameters(org.apache.camel.util.jsse.TrustManagersParameters) KeyStoreParameters(org.apache.camel.util.jsse.KeyStoreParameters) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 14 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class ConsulRoutePolicyMain method main.

public static void main(final String[] args) throws Exception {
    Main main = new Main();
    main.addRouteBuilder(new RouteBuilder() {

        public void configure() {
            ConsulRoutePolicy policy = new ConsulRoutePolicy();
            policy.setConsulUrl(ConsulConstants.CONSUL_DEFAULT_URL);
            policy.setServiceName(args[0]);
            policy.setTtl(15);
            from("file:///tmp/camel?delete=true").routeId(args[1]).routePolicy(policy).setHeader("ConsulRouteID", simple("${routeId}")).setHeader("ConsulServiceName", constant(args[0])).to("log:org.apache.camel.component.consul?level=INFO&showAll=true");
        }
    });
    main.run();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Main(org.apache.camel.main.Main)

Example 15 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class CometdProducerConsumerInOutInteractiveMain method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {

        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());
            from(URI, URIS).setExchangePattern(ExchangePattern.InOut).process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Message out = new DefaultMessage();
                    out.setBody("reply: " + exchange.getIn().getBody());
                    exchange.setOut(out);
                }
            });
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) File(java.io.File) URI(java.net.URI)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)1744 Exchange (org.apache.camel.Exchange)624 Processor (org.apache.camel.Processor)542 Test (org.junit.Test)470 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)338 CamelExecutionException (org.apache.camel.CamelExecutionException)135 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)119 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)100 File (java.io.File)65 IOException (java.io.IOException)61 CamelContext (org.apache.camel.CamelContext)61 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)42 HashMap (java.util.HashMap)34 Path (org.apache.hadoop.fs.Path)34 CountDownLatch (java.util.concurrent.CountDownLatch)32 Configuration (org.apache.hadoop.conf.Configuration)32 ArrayFile (org.apache.hadoop.io.ArrayFile)30 SequenceFile (org.apache.hadoop.io.SequenceFile)30 Endpoint (org.apache.camel.Endpoint)27 RuntimeCamelException (org.apache.camel.RuntimeCamelException)26