org.apache.camel.builder.ThreadPoolBuilder Java Examples

The following examples show how to use org.apache.camel.builder.ThreadPoolBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThreadPoolBuilderTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create a thread pool builder
            ThreadPoolBuilder builder = new ThreadPoolBuilder(context);

            // use thread pool builder to create a custom thread pool
            ExecutorService myPool = builder.poolSize(5).maxPoolSize(25).maxQueueSize(200).build("MyPool");

            from("direct:start")
                // use our custom pool in the threads DSL
                .threads().executorService(myPool)
                    .to("log:cool")
                    .to("mock:result")
                .end();
        }
    };
}
 
Example #2
Source File: WireTapTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create a custom thread pool
            ExecutorService lowPool = new ThreadPoolBuilder(context)
                    .poolSize(1).maxPoolSize(5).build("LowPool");

            // which we want the WireTap to use
            from("direct:start")
                .log("Incoming message ${body}")
                .wireTap("direct:tap").executorService(lowPool)
                .to("mock:result");

            from("direct:tap")
                .log("Tapped message ${body}")
                .to("mock:tap");
        }
    };
}
 
Example #3
Source File: ThreadPoolBuilderTest.java    From camelinaction with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create a thread pool builder
            ThreadPoolBuilder builder = new ThreadPoolBuilder(context);

            // use thread pool builder to create a custom thread pool
            ExecutorService myPool = builder.poolSize(5).maxPoolSize(25).maxQueueSize(200).build("MyPool");

            from("direct:start")
                // use our custom pool in the threads DSL
                .threads().executorService(myPool)
                    .to("log:cool")
                    .to("mock:result")
                .end();
        }
    };
}
 
Example #4
Source File: WireTapTest.java    From camelinaction with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create a custom thread pool
            ExecutorService lowPool = new ThreadPoolBuilder(context)
                    .poolSize(1).maxPoolSize(5).build("LowPool");

            // which we want the WireTap to use
            from("direct:start")
                .log("Incoming message ${body}")
                .wireTap("direct:tap").executorService(lowPool)
                .to("mock:result");

            from("direct:tap")
                .log("Tapped message ${body}")
                .to("mock:tap");
        }
    };
}
 
Example #5
Source File: CustomThreadPoolInlineRoute.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Override
public void configure() throws Exception {
    CamelContext context = getContext();
    ExecutorService executorService = new ThreadPoolBuilder(context).poolSize(5).maxQueueSize(100).build("CustomThreadPool");

    from("direct:in")
        .log("Received ${body}:${threadName}")
        .threads().executorService(executorService)
        .log("Processing ${body}:${threadName}")
        .transform(simple("${threadName}"))
        .to("mock:out");
}
 
Example #6
Source File: WireTapCustomThreadPoolRoute.java    From camel-cookbook-examples with Apache License 2.0 5 votes vote down vote up
@Override
public void configure() throws Exception {

    ThreadPoolBuilder builder = new ThreadPoolBuilder(getContext());
    ExecutorService oneThreadOnly = builder.poolSize(1).maxPoolSize(1)
        .maxQueueSize(100).build("JustMeDoingTheTapping");

    from("direct:start")
        .wireTap("direct:tapped").executorService(oneThreadOnly)
        .to("mock:out");

    from("direct:tapped")
        .setHeader("threadName").simple("${threadName}")
        .to("mock:tapped");
}