Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:30:55+00:00 2026-06-14T23:30:55+00:00

Closely related to this question: How to use HttpClient with multithreaded operation? , I’m

  • 0

Closely related to this question: How to use HttpClient with multithreaded operation?, I’m wondering if apache HttpAsyncClient is thread safe, or if it, too, requires the use of a MultiThreadedHttpConnectionManager, or a ThreadSafeClientConnManager.

If it does require such a connection manager, does one exist in the async libraries?

I was able to find a PoolingClientAsyncConnectionManager in the async libraries, but I’m not sure if that’s what I need.

Alternately, I was thinking of using ThreadLocal to create one HttpAsyncClient object per thread.

Note that unlike the question I referenced earlier, I need state to be independent across sessions, even if multiple sessions hit the same domain. If a cookie is set in session 1, the cookie should not be visible to session 2. For this reason, I’ve also considered creating a brand new HttpAsyncClient object for every single request, though I get the impression there should be a better way.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:30:57+00:00Added an answer on June 14, 2026 at 11:30 pm

    After load testing both with and without the PoolingClientAsyncConnectionManager, we discovered that we got inconsistent results when we did not use the PoolingClientAsyncConnectionManager.

    Amongst other things, we tracked the number of Http calls we were making, and the number of Http calls that were completed (either through the cancelled(…), completed(…), or failed(…) functions of the associated FutureCallback). Without the PoolingClientAsyncConnectionManager, and under heavy load, the two figures sometimes did not match up, leading us to believe that somewhere, some connections were stomping on connection information from other threads (just a guess).

    Either way, with the PoolingClientAsyncConnectionManager, the figures always matched, and the load tests were all successful, so we are definitely using it.

    The final code we used goes like this:

    public class RequestProcessor {
      private RequestProcessor instance = new RequestProcessor();
      private PoolingClientAsyncConnectionManager pcm = null;
      private HttpAsyncClient httpAsyncClient = null;
      private RequestProcessor() {
        // Initialize the PoolingClientAsyncConnectionManager, and the HttpAsyncClient 
      }
      public void process(...) {
        this.httpAsyncClient.execute(httpMethod, 
             new BasicHttpContext(), // Use a separate HttpContext for each request so information is not shared between requests
             new FutureCallback<HttpResponse>() {
          @Override
          public void cancelled() {
            // Do stuff
          }
          @Override
          public void completed(HttpResponse httpResponse) {
            // Do stuff
          }
          @Override
          public void failed(Exception e) {
            // Do stuff
          }
        });
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is closely related to another question: How can I measure thread stack depth?
This is closely related to Is it safe to signal and immediately close a
This is closely related to another question I asked: Is there functionality that is
This is pretty closely related to another SO question. Using the example below, could
Preface: this question is closely related to these ones: ... - C++: Avoiding Static
This is closely related to anothewr question I have asked but since this is
This is closely related to a previous question i asked. I have a many-to-many
This is very closely related to this other question , but that question wanted
This question is closely related to this question . The difference is that I'd
This is closely related to, but is not the same question as: Java -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.