I am looking for something that runs http calls in a synchronous manner (i.e. in order) but that also keeps the connection open between calls.
I *think* that the HttpClient (using version 3 ) with the SimpleHttpConnectionManager would accomplish this goal. I setup one instance of the HttpClient then make multiple http calls with that client.
The problem is that during testing, I am seeing a bit of a race condition where two parts of the program are sometimes run in a different order and think it might be related to misunderstanding when to use the SimpleHttpConnectionManager . Can someone confirm that a single instance of the HttpClient with the SimpleHttpConnectionManager should run the calls in order?
I've checked out the SimpleHttpConnectionManager a short while ago, and I found out it makes no assumptions on thread safety at all. It's up to you, as developer, to make sure the calls are synchronous and sequential. Fortunately for me, my application was single threaded. Unfortunately for you, yours isn't so you'll have to work around that.
I think that keeping the proper viewpoint is what helps here.
The HttpConnectionManager is a factory for HttpConnection objects. The HttpClient uses an HttpConnectionManager to acquire the transport needed to execute Http method requests.
The docs plainly say that the connection manager doesn't protect an HttpConnection from being used for multiple requests simultaneously, but since an HttpConnection is responsible for a single request/response cycle at a time, that obliges the application to take proper care not to use it for multiple simultaneous requests.
As I read the docs, the HttpClient won't knowingly violate that limitation. However, if the HttpClient is itself being hit for multiple simultaneous method executions, then it also won't protect you. It's up to you so ensure that the HttpClient is being used serially.
Customer surveys are for companies who didn't pay proper attention to begin with.