Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7658F184A7 for ; Sat, 21 Nov 2015 15:32:29 +0000 (UTC) Received: (qmail 91370 invoked by uid 500); 21 Nov 2015 15:32:28 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 91320 invoked by uid 500); 21 Nov 2015 15:32:28 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 91308 invoked by uid 99); 21 Nov 2015 15:32:28 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2015 15:32:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 35413180A23 for ; Sat, 21 Nov 2015 15:32:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.15 X-Spam-Level: *** X-Spam-Status: No, score=3.15 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id KNz8cZBtQu7B for ; Sat, 21 Nov 2015 15:32:20 +0000 (UTC) Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com [209.85.218.48]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 79C9C439E9 for ; Sat, 21 Nov 2015 15:32:20 +0000 (UTC) Received: by oiww189 with SMTP id w189so80615444oiw.3 for ; Sat, 21 Nov 2015 07:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=TsWnvOX+J8q+K9W+drVS5xPkxp9KbXnZ7QY1xrTnYPE=; b=XUFrtBSGrqEg8KJivd9wrtDPammCk+AkxYSS808p8FuVAsmeUje9wSOaRi2MeYz5k3 bCq5lvp2/fQ0x6GQDSpossHYcisbRj6LwB5wJgUp0sBzxGgXZjY52+0cL7aMxjkjXXHH RYmV54d98zz9ePYkaGK1zd4S32ZYwzFmIFuPKZjtlb6TgM3pAwhQ6J2M5lA2PYg5tIAb /QTe2JfxJ2bwJSZH9H/CGNWbzmtwKAZAI4Ctyy3w6mHynOj1pNFhLZCxeqfODYOO+F5s 4NWm/VKFoopbIKG5wP3hnzv1uCop3n824ncrDpAmLZzz2lG3e9MbxZZMJ2wCh8gBKuDs ZVAg== MIME-Version: 1.0 X-Received: by 10.202.77.136 with SMTP id a130mr10400340oib.123.1448119934001; Sat, 21 Nov 2015 07:32:14 -0800 (PST) Received: by 10.202.173.201 with HTTP; Sat, 21 Nov 2015 07:32:13 -0800 (PST) In-Reply-To: References: Date: Sat, 21 Nov 2015 08:32:13 -0700 Message-ID: Subject: Re: Camel ThreadPool maxQueueSize question From: David Hoffer To: users@camel.apache.org Content-Type: multipart/alternative; boundary=001a1134e88842591a05250eb215 --001a1134e88842591a05250eb215 Content-Type: text/plain; charset=UTF-8 I have more information on my case. It turns out that the reason the sftp endpoint stopped poling and processing was that it got an out of memory error. However the strange part is I would expect that to kill Camel and everything would stop but that's not what was happening as other threads/routes continued to run as I saw tons of additional application logging after that before so didn't notice there was an out of memory error much earlier. So how does Camel handle memory/heap errors? Again I would think it would just stop but not sure. Our app runs as service so its possible the service is configured to catch memory errors and restart the app. I inherited this app so don't yet know how if its the service that is restarting it in this case. Btw, the reason I am investigating this is that we have had several reports of our app in production where the sftp endpoint either slows down or just stops. (Users can manually move the files from the SFTP endpoint into the next route when Camel stops doing it and the rest of the routes are fine.) I thought I had finally been able to re-create this issue in house but now that I see mine was caused by a memory error I doubt its the same issue reported in production as this doesn't explain any slowdown. -Dave On Sat, Nov 21, 2015 at 1:40 AM, Claus Ibsen wrote: > Set queue size to 0 or -1 or to have no queue and a direct handover > with that synchronous queue. And then configure the rejected policy to > decide what to do if there is no free threads, such as reject or use > current thread etc. > > On Fri, Nov 20, 2015 at 11:09 PM, David Hoffer wrote: > > This part I'm not clear on and it raises more questions. > > > > When using the JDK one generally uses the Executors factory methods to > > create either a Fixed, Single or Cached thread tool. These will use a > > SynchronousQueue for Cached pools and LinkedBlockingQueue for Fixed or > > Single pools. In the case of SynchronousQueue there is no size...it > simply > > hands the new request off to either a thread in the pool or it creates a > > new one. And in the case of LinkedBlockingQueue it uses an unbounded > queue > > size. Now it is possible to create a hybrid, e.g. LinkedBlockingQueue > with > > a max size but its not part of the factory methods or common. Another > > option is the ArrayBlockingQueue which does use a max size but none of > the > > factory methods use this type. > > > > So what type of thread pool does Camel create for the default thread > pool? > > Since its not fixed size I assumed it would use SynchronousQueue and not > > have a separate worker queue. However if Camel is creating a hybrid > using > > a LinkedBlockingQueue or ArrayBlockingQueue is there a way I can change > > that to be a SynchronousQueue so no queue? Or is there a compelling > reason > > to use LinkedBlockingQueue in a cached pool? > > > > Now this gets to the problem I am trying to solve. We have a Camel app > > that deals with files, lots of them...e.g. all the routes deal with > files. > > It starts with an sftp URL that gets files off a remote server and then > > does a lot of subsequent file processing. The problem is that if the > SFTP > > server has 55 files (example) and I start the Camel app it processes them > > fine until about 14 or 15 files are left and then it just stops. The > > thread that does the polling of the server stops (at least it appears to > > have stopped) and the processing of the 55 files stops, e.g. it does not > > continue to process all of the original 55 files, it stops with 14-15 > left > > to process (and it never picks them up again on the next poll). And I > have > > a breakpoint on my custom SftpChangedExclusiveReadLockStrategy and it > never > > is called again. > > > > Now getting back to the default thread pool and changing it I would like > to > > change it so it uses more threads and no worker queue (like a standard > > Executors cached thread pool) but I'm not certain that would even help as > > in the debugger & thread dumps I see that it looks like the SFTP endpoint > > uses a Scheduled Thread Pool instead which makes sense since its a > polling > > (every 60 seconds in my case) operation. So is there another default > pool > > that I can configure for Camel's scheduled threads? > > > > All that being said why would the SFTP endpoint just quit? I don't see > any > > blocked threads and no deadlock. I'm new to Camel and just don't know > > where to look for possible causes of this. > > > > Thanks, > > -Dave > > > > > > On Thu, Nov 19, 2015 at 11:40 PM, Claus Ibsen > wrote: > > > >> Yes its part of JDK as it specifies the size of the worker queue, of > >> the thread pool (ThreadPoolExecutor) > >> > >> For more docs see > >> http://camel.apache.org/threading-model.html > >> > >> Or the Camel in Action books > >> > >> > >> On Fri, Nov 20, 2015 at 12:22 AM, David Hoffer > wrote: > >> > I'm trying to understand the default Camel Thread Pool and how the > >> > maxQueueSize is used, or more precisely what's it for? > >> > > >> > I can't find any documentation on what this really is or how it's > used. > >> I > >> > understand all the other parameters as they match what I'd expect from > >> the > >> > JDK...poolSize is the minimum threads to keep in the pool for new > tasks > >> and > >> > maxPoolSize is the maximum number of the same. > >> > > >> > So how does maxQueueSize fit into this? This isn't part of the JDK > >> thread > >> > pool so I don't know how Camel uses this. > >> > > >> > The context of my question is that we have a from sftp route that > seems > >> to > >> > be getting thread starved. E.g. the thread that polls the sftp > >> connection > >> > is slowing/stopping at times when it is busy processing other files > that > >> > were previously downloaded. > >> > > >> > We are using the default camel thread pool that I see has only a max > of > >> 20 > >> > threads yet a maxQueueSize of 1000. That doesn't make any sense to me > >> > yet. I would think one would want a much larger pool of threads (as > we > >> are > >> > processing lots of files) but no queue at all...but not sure on that > as I > >> > don't understand how the queue is used. > >> > > >> > -Dave > >> > >> > >> > >> -- > >> Claus Ibsen > >> ----------------- > >> http://davsclaus.com @davsclaus > >> Camel in Action 2: https://www.manning.com/ibsen2 > >> > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > --001a1134e88842591a05250eb215--