Examples of ThreadPoolTaskExecutor


Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * 200;
                    for (int i = 0; i < 200; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    return serviceChanges;
  }

  protected TaskExecutor getTunnelServerThreadExecutor() {
    int defaultPoolSize = 20;
    ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
    te.setCorePoolSize(defaultPoolSize);
    te.setMaxPoolSize(defaultPoolSize * 2);
    te.setQueueCapacity(100);
    return te;
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    public boolean isUseRouteBuilder() {
        return false;
    }

    private void sendMessagesToQueue() throws Exception {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.afterPropertiesSet();
        executor.execute(new Runnable() {
            public void run() {
                for (int i = 0; i < 10; i++) {
                    // when this delay is removed, the seda endpoint has ordering issues
                    try {
                        // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    public void testConcurrentConsumersWithReply() throws Exception {
        // latch for the 5 exchanges we expect
        final CountDownLatch latch = new CountDownLatch(5);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int count = i;
            executor.execute(new Runnable() {
                public void run() {
                    // request body is InOut pattern and thus we expect a reply (JMSReply)
                    Object response = template.requestBody("activemq:a", "World #" + count);
                    assertEquals("Bye World #" + count, response);
                    latch.countDown();
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        }
        super.tearDown();
    }

    protected TaskExecutor createTaskExecutor() {
        ThreadPoolTaskExecutor exec = new CleanThreadPoolTaskExecutor();
        exec.setWaitForTasksToCompleteOnShutdown(true);
        exec.setQueueCapacity(0);
        exec.afterPropertiesSet();
        return exec;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    public void testConcurrentConsumersWithReply() throws Exception {
        // latch for the 5 exchanges we expect
        final CountDownLatch latch = new CountDownLatch(5);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int count = i;
            executor.execute(new Runnable() {
                public void run() {
                    // request body is InOut pattern and thus we expect a reply (JMSReply)
                    Object response = template.requestBody("activemq:a", "World #" + count);
                    assertEquals("Bye World #" + count, response);
                    latch.countDown();
                }
            });
        }

        long start = System.currentTimeMillis();

        // wait for test completion, timeout after 30 sec to let other unit test run to not wait forever
        latch.await(30000L, TimeUnit.MILLISECONDS);
        assertEquals("Latch should be zero", 0, latch.getCount());

        long delta = System.currentTimeMillis() - start;
        assertTrue("Should be faster than 20000 millis, took " + delta + " millis", delta < 20000L);
        executor.shutdown();
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * 200;
                    for (int i = 0; i < 200; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
                            Thread.sleep(new Random().nextInt(10));
                        } catch (InterruptedException e) {
                            // ignore
                        }
                        template.sendBody(uri, "<person><id>" + (start + i + 1) + "</id><name>James</name></person>");
                    }
                }
            });
        }

        mock.assertNoDuplicates(body());

        assertMockEndpointsSatisfied();
        executor.shutdown();
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        int total = 200;
        final int group = total / 20;
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(20);
        executor.afterPropertiesSet();
        for (int i = 0; i < 20; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * group;
                    for (int i = 0; i < group; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * 200;
                    for (int i = 0; i < 200; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        // latch for the 5 exchanges we expect
        final CountDownLatch latch = new CountDownLatch(5);
        long start = System.currentTimeMillis();

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int count = i;
            executor.execute(new Runnable() {
                public void run() {
                    // requestbody is InOut pattern and thus we expect a reply (JMSReply)
                    Object response = template.requestBody("activemq:a", "World #" + count);
                    assertEquals("Bye World #" + count, response);
                    latch.countDown();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.