Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 87683 invoked from network); 27 Sep 2007 15:42:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Sep 2007 15:42:20 -0000 Received: (qmail 30861 invoked by uid 500); 27 Sep 2007 15:42:09 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 30848 invoked by uid 500); 27 Sep 2007 15:42:09 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 30837 invoked by uid 99); 27 Sep 2007 15:42:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2007 08:42:09 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [212.227.126.174] (HELO moutng.kundenserver.de) (212.227.126.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Sep 2007 15:44:30 +0000 Received: from [85.180.1.194] (helo=[85.180.1.194]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis) id 0MKxQS-1IavUq2Pwn-0008E0; Thu, 27 Sep 2007 17:41:48 +0200 Message-ID: <46FBCF62.60201@dubioso.net> Date: Thu, 27 Sep 2007 17:42:26 +0200 From: Roland Weber User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070807 SeaMonkey/1.1.4 MIME-Version: 1.0 To: HttpClient User Discussion Subject: Re: Using MultiThreadedHttpConnectionManager in a Servlet References: <241399.40289.qm@web81714.mail.mud.yahoo.com> In-Reply-To: <241399.40289.qm@web81714.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1803VdWmmdouOc4eTYA7/BuMeY9u6Bc3dIWzX4 Jrkik+IjIdvkepFc/iyXZDX1FLoi2+m+u3QMmEPBYo4gNbOJnC nGp3OBu4kBWeZVxpPvjYEr+eNvpUhqX X-Virus-Checked: Checked by ClamAV on apache.org Hello Josh, Josh Fix wrote: > Is it possible to have multiple threads from my servlet > open simultaneous connections to an external web site with > different requests and read the results? Sure. That's what the MultiThreadedHttpConnectionManager is there for. > I would really like to get around the blocking aspect of > the read statements. What are your settings for the connections-per-host and total-connections limits? Default for CPH is 2, as that is mentioned in RFC 2616. Since you're operating some kind of proxy agent, you are entitled to use 2 per client for which your servlet is acting. http://jakarta.apache.org/httpcomponents/httpclient-3.x/threading.html > My servlet declares the MTHCM as a static object in the > servlet class, so that once instance is shared amongst all > incoming servlet requests, and a static{} block is used in > the class to set timeouts/etc. Bad style, but probably irrelevant for the problem at hand. You should declare shared objects as non-static attributes of the servlet and initialize them in the Servlet.init() method. > The HttpClient is newed in the doGet method. Unless you need different parameters for the instances, that is not a good idea. Use one client object and set specific parameters at the method you are executing. Our preferences hierarchies do not respond well to using multiple clients with the same MTHCM. There can be only one parent to the connection manager params. hope that helps, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org