Hi See ticket https://issues.apache.org/jira/browse/CAMEL-5079
On Tue, Mar 13, 2012 at 11:00 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > On Tue, Mar 13, 2012 at 9:13 AM, ShlomiJ <shlomij...@gmail.com> wrote: >> OK, I'm a bit more knowledgeable now... >> >> The first issue is that I thought I created a pool of 1 thread. >> >> ShlomiJ wrote >>> ThreadPoolBuilder tpBuilder = new ThreadPoolBuilder(this.context); >>> ExecutorService wiretapThreadpool = >>> tpBuilder.poolSize(*1*).maxPoolSize(*1*).maxQueueSize(*1*).build("WireTap"); >>> registry.put(WIRETAP_THREADPOOL, wiretapThreadpool); >> But I did not. The pool created was actually of 10 threads. >> So once 10 messages passed in the route, all 10 threads have been created >> and reused. >> > > There was an issue in Camel 2.9.1 or older. Can you try with trunk. It > ought to use the thread pool as given. > > >> Another issue is the number of calls to wireTap and the way the pool is >> used. >> >> ShlomiJ wrote >>> from("quartz://myScheduler?cron=0+*+*+*+*+?") >>> .process(new MyMessageSetterProcessor()) >>> .wireTap("seda:wireTapQueue").onPrepare(new >>> MyCloneProcessor()).*executorServiceRef*(WIRETAP_THREADPOOL) >>> .log("${body}") >> I now understand that each route has its own pool. So I have (10 * >> #schedules) threads of wiretap. >> >> *But the real issue is that the wiretap threads (maybe others also?) are not >> removed when the route is removed.* >> I remove a route with CamelContext.getRoute(String) -> >> CamelContext.stopRoute(String) -> CamelContext.removeRoute(String). >> The last method returns true, but the wiretap threads are still alive. >> > > When you provide an existing thread pool to any Camel EIPs, such as > the WireTap, then > YOU are in control of the lifecycle of the thread pool. So you have to > shutdown this thread pool yourself, > when its no longer in-use. Camel does not know whether it would be > safe to shutdown a shared thread pool it was given. > > Only if Camel itself creates the thread pool, then it handles the > lifecycle, and will shutdown the thread pool itself, > but that happens normally only when Camel is shutdown itself. > > We could possible improve this to detect in the EIPs whether the > thread pool can safely be shutdown when the route > is removed or not. I will log a JIRA about this. > > >> I'm using Camel 2.9.0. >> thanks >> SJ >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/WireTap-threads-number-keeps-on-growing-tp5557827p5560267.html >> Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/