Java-Mandrill-Wrapper
Java-Mandrill-Wrapper copied to clipboard
Multi-Thread issue
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.
Nothing in your comment would require modifying method signatures. Was there something else required?
Is this issue resolved? we are currently experiencing similar issues.
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.
we figured out that the issue was something else