You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by serega <se...@sybase.com> on 2010/10/11 19:50:38 UTC

ThreadPoolExecutor configuration

Hi.
Here is the scenario:
public static void main(String[] args) throws Exception {
        BasicConfigurator.configure();
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
            public void configure() throws Exception {
                from(new BeanEndpoint())
                        .threads(4)
                        .threadName("t1")
                        .process(new AsyncProcessor() {
                            public boolean process(Exchange exchange,
AsyncCallback callback) {
                                try {
                                    process(exchange);
                                } catch (Exception e) {}
                                callback.done(false);
                                return false;
                            }
                            public void process(Exchange exchange) throws
Exception {}
                        })
                        .threads(0)
                        .maxPoolSize(2)
                        .threadName("t2")
                        .maxQueueSize(0)
                        .process(new AsyncProcessor() {
                            public boolean process(Exchange exchange,
AsyncCallback callback) {
                                try {
                                    process(exchange);
                                } catch (Exception e) {}
                                callback.done(false);
                                return false;
                            }

                            public void process(Exchange exchange) throws
Exception {}
                        })
                        .to(new BeanEndpoint());

            }});
            context.start();
        }
    }


In the log I see the following:

737 [main] DEBUG org.apache.camel.impl.DefaultExecutorServiceStrategy  -
Created new thread pool for source:
Threads[[process[com.sybase365.CamelTest2$1$2@49dc423f],
Threads[[process[com.sybase365.CamelTest2$1$1@1b815bfb], To[bean:null]]]]]
with name: t1. [poolSize=4, maxPoolSize=6, keepAliveTime=60 SECONDS,
maxQueueSize=1,
rejectedExecutionHandler=java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy@63b0bdc8,
daemon=true] -> java.util.concurrent.ThreadPoolExecutor@12b754b2
...
907 [main] DEBUG org.apache.camel.impl.DefaultExecutorServiceStrategy  -
Created new thread pool for source:
Threads[[process[com.sybase365.CamelTest2$1$1@1b815bfb], To[bean:null]]]
with name: t2. [poolSize=10, maxPoolSize=20, keepAliveTime=60 SECONDS,
maxQueueSize=1000,
rejectedExecutionHandler=java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy@69d95da8,
daemon=false] -> java.util.concurrent.ThreadPoolExecutor@50d17ec3

The first Executor is configured as specified; the second Executor uses only
thread name "t2",
but  why did't it use the rest of configuration parameters?

Thanks,
Sergey.


-- 
View this message in context: http://camel.465427.n5.nabble.com/ThreadPoolExecutor-configuration-tp3207845p3207845.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ThreadPoolExecutor configuration

Posted by Claus Ibsen <cl...@gmail.com>.
Yeah wait for Camel 2.5 then

On Tue, Oct 12, 2010 at 3:54 PM, serega <se...@sybase.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> The problem is that you are using 0 as the pool size.
>>     .threads(0)
>>
>> If you use 1 or larger it should work
>>
> Yes. I tried with threads(1) and it worked.
> But if I use pool size greater then 0,  I cannot get SynchronousQueue.
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java?revision=997755&view=markup
> The lines 209 - 218.
> --
> View this message in context: http://camel.465427.n5.nabble.com/ThreadPoolExecutor-configuration-tp3207845p3208923.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: ThreadPoolExecutor configuration

Posted by serega <se...@sybase.com>.

Claus Ibsen-2 wrote:
> 
> Hi
> 
> The problem is that you are using 0 as the pool size.
>     .threads(0)
> 
> If you use 1 or larger it should work
> 
Yes. I tried with threads(1) and it worked.
But if I use pool size greater then 0,  I cannot get SynchronousQueue.
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/concurrent/ExecutorServiceHelper.java?revision=997755&view=markup
The lines 209 - 218.
-- 
View this message in context: http://camel.465427.n5.nabble.com/ThreadPoolExecutor-configuration-tp3207845p3208923.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ThreadPoolExecutor configuration

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The problem is that you are using 0 as the pool size.
    .threads(0)

If you use 1 or larger it should work

I will fix the issue so you can define 0 as the pool size.


On Mon, Oct 11, 2010 at 7:50 PM, serega <se...@sybase.com> wrote:
>
> Hi.
> Here is the scenario:
> public static void main(String[] args) throws Exception {
>        BasicConfigurator.configure();
>        CamelContext context = new DefaultCamelContext();
>        context.addRoutes(new RouteBuilder() {
>            public void configure() throws Exception {
>                from(new BeanEndpoint())
>                        .threads(4)
>                        .threadName("t1")
>                        .process(new AsyncProcessor() {
>                            public boolean process(Exchange exchange,
> AsyncCallback callback) {
>                                try {
>                                    process(exchange);
>                                } catch (Exception e) {}
>                                callback.done(false);
>                                return false;
>                            }
>                            public void process(Exchange exchange) throws
> Exception {}
>                        })
>                        .threads(0)
>                        .maxPoolSize(2)
>                        .threadName("t2")
>                        .maxQueueSize(0)
>                        .process(new AsyncProcessor() {
>                            public boolean process(Exchange exchange,
> AsyncCallback callback) {
>                                try {
>                                    process(exchange);
>                                } catch (Exception e) {}
>                                callback.done(false);
>                                return false;
>                            }
>
>                            public void process(Exchange exchange) throws
> Exception {}
>                        })
>                        .to(new BeanEndpoint());
>
>            }});
>            context.start();
>        }
>    }
>
>
> In the log I see the following:
>
> 737 [main] DEBUG org.apache.camel.impl.DefaultExecutorServiceStrategy  -
> Created new thread pool for source:
> Threads[[process[com.sybase365.CamelTest2$1$2@49dc423f],
> Threads[[process[com.sybase365.CamelTest2$1$1@1b815bfb], To[bean:null]]]]]
> with name: t1. [poolSize=4, maxPoolSize=6, keepAliveTime=60 SECONDS,
> maxQueueSize=1,
> rejectedExecutionHandler=java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy@63b0bdc8,
> daemon=true] -> java.util.concurrent.ThreadPoolExecutor@12b754b2
> ...
> 907 [main] DEBUG org.apache.camel.impl.DefaultExecutorServiceStrategy  -
> Created new thread pool for source:
> Threads[[process[com.sybase365.CamelTest2$1$1@1b815bfb], To[bean:null]]]
> with name: t2. [poolSize=10, maxPoolSize=20, keepAliveTime=60 SECONDS,
> maxQueueSize=1000,
> rejectedExecutionHandler=java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy@69d95da8,
> daemon=false] -> java.util.concurrent.ThreadPoolExecutor@50d17ec3
>
> The first Executor is configured as specified; the second Executor uses only
> thread name "t2",
> but  why did't it use the rest of configuration parameters?
>
> Thanks,
> Sergey.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/ThreadPoolExecutor-configuration-tp3207845p3207845.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus