Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Multi-Thread issue #22

Open
mettini opened this issue Jan 2, 2014 · 4 comments
Open

Multi-Thread issue #22

mettini opened this issue Jan 2, 2014 · 4 comments

Comments

@mettini
Copy link

mettini commented Jan 2, 2014

Hi,

I'm having some problems when I try to send messages in a multi-thread scenario (with the same httpclient instance, using PoolingHttpClientConnectionManager).

After the message is sent in MandrillRESTRequest, the connections aren't closed; when the app reaches the max conn set in httpclient, the messages get blocked and aren't sent.

I fixed it making a copy of MandrillRESTRequest in my working directory and converting HttpClient to CloseableHttpClient (httpclient 4.3.1) and HttpResponse to CloseableHttpResponse, to be able to do this modification:

try {
entity = response.getEntity();
} finally {
response.close();
}
BufferedReader br = new BufferedReader(new InputStreamReader((entity.getContent())));

(this recommendation of closing the connection in a multi-thread environment is detailed here: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e392).

Maybe there's a way to do this connection close without modifying method signature.

@cribbstechnologies
Copy link
Owner

Nothing in your comment would require modifying method signatures. Was there something else required?

@aluedeke
Copy link

Is this issue resolved? we are currently experiencing similar issues.

@cribbstechnologies
Copy link
Owner

No, I haven't looked at it since mettini never replied. If you replicate the suggested changes, test it, and issue a pull I'll merge it and re-publish the jar in Sonatype.

@aluedeke
Copy link

aluedeke commented Feb 10, 2015 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants