hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m0j0j0j0 <silvio.technolog...@gmail.com>
Subject Re: Help with Multiple Connections
Date Tue, 21 Feb 2012 14:50:38 GMT

olegk wrote:
> On Mon, 2012-02-20 at 21:16 -0800, m0j0j0j0 wrote:
>> Ive sorted my problem out i believe, thank you very much.
>> I still throw a few exceptions but it appears the httpclient is auto
>> recovering from it as it should
>> what i did was set the timeout improperly for the threads that initiate
>> the
>> get threads.  
>> So far seems to be working perfect for me.
> This all makes no sense of so ever. java.lang.IllegalStateException:
> 'Connection pool shut down' is thrown because some piece of code in your
> application shut down the connection manager, which is something that
> should never happen if your application intends to continue using it.
> Oleg

creating every thread, starting every thread, then joining every thread was
working.  I continuously received exceptions and timeouts when performing
many gets

My thinking was that i need to limit the ammount of threads connection
manager is using.
So i decided to through in a executor thread that will only dispatch so many
threads depending
on if they're still active or not it continues on to create new threads.

My  exe.awaittermination was set to 30 seconds so my executor would run for
30 seconds 
then kill all threads its started before it finished. I noticed this
yesterday, and changed the 
awaittermination code.  

I realize i can do something more elegant but for now it solved my problem
and httpclient 
seems to be working as it should for me.

So basically it was my fault nothint to do with httpclient

        	ExecutorService exec = Executors.newFixedThreadPool(500);
            try {
				for (int j = 0; j < dmdl1.getRowCount(); j++) {
					exec.execute(new GetThread(httpclient, new HttpGet(dmdl1.getValueAt(j,
2).toString()), j + 1, dmdl1, (ThreadSafeClientConnManager) cm));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				System.out.println("THREAD PROBLEM");
            /* The tasks are now running concurrently. We wait until all
work is done, 
			 * with a timeout of 50 seconds: */
            boolean b = exec.awaitTermination(1, TimeUnit.DAYS);
			/* If the execution timed out, false is returned: */
			System.out.println("All done: ");// + //)b);
View this message in context: http://old.nabble.com/Help-with-Multiple-Connections-tp33350254p33364362.html
Sent from the HttpClient-User mailing list archive at Nabble.com.

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message