Java-Mandrill-Wrapper icon indicating copy to clipboard operation
Java-Mandrill-Wrapper copied to clipboard

Multi-Thread issue

Open mettini opened this issue 11 years ago • 4 comments

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.

mettini avatar Jan 02 '14 16:01 mettini

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

cribbstechnologies avatar Aug 27 '14 12:08 cribbstechnologies

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

aluedeke avatar Feb 10 '15 10:02 aluedeke

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.

cribbstechnologies avatar Feb 10 '15 14:02 cribbstechnologies

we figured out that the issue was something else

aluedeke avatar Feb 10 '15 14:02 aluedeke