Hello,

In my async client pool, I’ve currently  set up a select interval of 1000ms.
But I need to control response timeouts of 50ms, 100ms, etc.

So I’have tried to implement something like this in the 'consumeContent'
method of my 'HttpAsyncResponseConsumer':

public void consumeContent(final ContentDecoder decoder, final IOControl
ioctrl) throws IOException 
 {
  int numBytesRead;

  if (this.bbuf == null) 
  {
   this.bbuf  = ByteBuffer.allocate(32768);
   this.vbaos = new VentusByteArrayOutputStream();
  }

  // If the difference between now and the starting point of the request
(when I sent it to the server) is greater than 8ms, throw a
SocketTimeoutException.
  long diff = System.currentTimeMillis() - this.startTime;
  if (diff >= 8) throw new java.net.SocketTimeoutException("Socket timeout
:: consumeContent :: [ " + diff + "ms > " + "8ms ]");

  while ( (numBytesRead = decoder.read(this.bbuf)) > 0 ) 
  {
   this.vbaos.write(this.bbuf.array(), 0, numBytesRead);
   this.bbuf.clear();
  }
 }

And it seems to work. The exception is thrown, the consumeContent is no
longer called, the 'responseCompleted' method is not called, and the async
client calls the 'failed' method that logs the exception correctly.

My question is: can I be sure that the response reading was stopped, the
connection was aborted (even without completing the response reading) and
the thread was released?

Thanks,

Joan.



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

Reply via email to