Package org.apache.camel.spi

Examples of org.apache.camel.spi.ThreadPoolProfile


    @Override
    protected CamelContext createCamelContext() throws Exception {
        CamelContext camel = super.createCamelContext();

        ThreadPoolProfile profile = new ThreadPoolProfileSupport("custom");
        profile.setPoolSize(5);
        profile.setMaxPoolSize(15);
        profile.setKeepAliveTime(25L);
        profile.setMaxQueueSize(250);
        profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

        camel.getExecutorServiceStrategy().setDefaultThreadPoolProfile(profile);
        return camel;
    }
View Full Code Here


        camel.getExecutorServiceStrategy().setDefaultThreadPoolProfile(profile);
        return camel;
    }

    public void testCamelCustomDefaultThreadPoolProfile() throws Exception {
        ThreadPoolProfile profile = context.getExecutorServiceStrategy().getDefaultThreadPoolProfile();
        assertEquals(5, profile.getPoolSize().intValue());
        assertEquals(15, profile.getMaxPoolSize().intValue());
        assertEquals(25, profile.getKeepAliveTime().longValue());
        assertEquals(250, profile.getMaxQueueSize().intValue());
        assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
    }
View Full Code Here

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // create a profile for the throttler
                ThreadPoolProfile profile = new ThreadPoolProfileSupport("myThrottler");
                profile.setMaxPoolSize(5);
                profile.setMaxQueueSize(2);
                context.getExecutorServiceStrategy().registerThreadPoolProfile(profile);
               
                from("seda:start")
                    .throttle(1).timePeriodMillis(100)
                        .asyncDelayed().executorServiceRef("myThrottler").callerRunsWhenRejected(true)
View Full Code Here

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // create and register thread pool profile
                ThreadPoolProfile profile = new ThreadPoolProfileSupport("myProfile");
                profile.setPoolSize(2);
                profile.setMaxPoolSize(8);
                profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
                context.getExecutorServiceStrategy().registerThreadPoolProfile(profile);

                from("direct:start")
                    .aggregate(header("id"), new BodyInAggregatingStrategy())
                        // use our custom thread pool profile
View Full Code Here

            // camel context will shutdown the executor when it shutdown so no need to shut it down when stopping
            if (executorServiceRef != null) {
                executorService = camelContext.getRegistry().lookup(executorServiceRef, ScheduledExecutorService.class);
                if (executorService == null) {
                    ExecutorServiceManager manager = camelContext.getExecutorServiceManager();
                    ThreadPoolProfile profile = manager.getThreadPoolProfile(executorServiceRef);
                    executorService = manager.newScheduledThreadPool(this, executorServiceRef, profile);
                }
                if (executorService == null) {
                    throw new IllegalArgumentException("ExecutorServiceRef " + executorServiceRef + " not found in registry.");
                }
View Full Code Here

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                ThreadPoolProfile profile = new ThreadPoolProfileSupport("custom");
                profile.setPoolSize(5);
                profile.setMaxPoolSize(15);
                profile.setKeepAliveTime(25L);
                profile.setMaxQueueSize(250);
                profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

                context.getExecutorServiceStrategy().registerThreadPoolProfile(profile);

                from("direct:start").threads().executorServiceRef("custom").to("mock:result");
            }
View Full Code Here

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                ThreadPoolProfile profile = new ThreadPoolProfileSupport("custom");
                profile.setPoolSize(5);
                profile.setMaxPoolSize(15);
                profile.setKeepAliveTime(25L);
                profile.setMaxQueueSize(250);
                profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

                context.getExecutorServiceStrategy().registerThreadPoolProfile(profile);

                from("direct:start").threads().executorServiceRef("custom").to("mock:result");
View Full Code Here

    @Override
    protected CamelContext createCamelContext() throws Exception {
        CamelContext camel = super.createCamelContext();

        ThreadPoolProfile profile = new ThreadPoolProfile("custom");
        profile.setPoolSize(5);
        profile.setMaxPoolSize(15);
        profile.setKeepAliveTime(25L);
        profile.setMaxQueueSize(250);
        profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

        camel.getExecutorServiceManager().setDefaultThreadPoolProfile(profile);
        return camel;
    }
View Full Code Here

        return camel;
    }

    public void testCamelCustomDefaultThreadPoolProfile() throws Exception {
        DefaultExecutorServiceManager manager = (DefaultExecutorServiceManager)context.getExecutorServiceManager();
        ThreadPoolProfile profile = manager.getDefaultThreadPoolProfile();
        assertEquals(5, profile.getPoolSize().intValue());
        assertEquals(15, profile.getMaxPoolSize().intValue());
        assertEquals(25, profile.getKeepAliveTime().longValue());
        assertEquals(250, profile.getMaxQueueSize().intValue());
        assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
    }
View Full Code Here

public class ThreadPoolProfileBuilder {
    private final ThreadPoolProfile profile;

    public ThreadPoolProfileBuilder(String id) {
        this.profile = new ThreadPoolProfile(id);
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.ThreadPoolProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.