Ding Jinqiang created AMQ-6233:
----------------------------------
Summary: Causing server OOM when publishing messages through
RESTful API without clientId param
Key: AMQ-6233
URL: https://issues.apache.org/jira/browse/AMQ-6233
Project: ActiveMQ
Issue Type: Bug
Affects Versions: 5.13.2
Reporter: Ding Jinqiang
When I firstly try using the RESTful API to produce messages, I found that
ActiveMQ soon ran into OOM Error, and then I found out that it is because:
1. I didn't send a clientId param
2. I use the plain HttpURLConnection to send request, without maintaining
cookies.
According to org.apache.activemq.web.MessageServlet#getWebClient
and
org.apache.activemq.web.WebClient#getWebClient(javax.servlet.http.HttpServletRequest):
{code:borderStyle=solid}
/** org.apache.activemq.web.MessageServlet#getWebClient **/
public WebClient getWebClient(HttpServletRequest request) {
String clientId = request.getParameter("clientId");
if (clientId != null) {
synchronized (this) {
LOG.debug("Getting local client [" + clientId + "]");
WebClient client = clients.get(clientId);
if (client == null) {
LOG.debug("Creating new client [" + clientId + "]");
client = new WebClient();
clients.put(clientId, client);
}
return client;
}
} else {
return WebClient.getWebClient(request);
}
}
/**
org.apache.activemq.web.WebClient#getWebClient(javax.servlet.http.HttpServletRequest
**/
public static WebClient getWebClient(HttpServletRequest request) {
HttpSession session = request.getSession(true);
WebClient client = getWebClient(session);
if (client == null || client.isClosed()) {
client = WebClient.createWebClient(request);
session.setAttribute(WEB_CLIENT_ATTRIBUTE, client);
}
return client;
}
{code}
I finally found that it will create new WebClient every time I publish a new
message, which soon drain total memory.
To my mind, solution is, either doing some stuff to prevent that case (maybe
using a default webClient instead of creating new one) or explaining it
seriously in your documantation at http://activemq.apache.org/rest.html
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)