activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Loth <>
Subject ActiveMQ 5.2.0 + REST + java.lang.OutOfMemoryError
Date Fri, 01 May 2009 14:47:32 GMT

First off, I am a newbie when it comes to JMS & ActiveMQ.

I have been looking into a messaging solution to serve as middleware for a
message producer that will insert XML messages into a queue via HTTP POST. 
The producer is an existing system written in C++ that cannot be modified
(so Java and the C++ API are out).

Using the "demo" examples and some trial and error, I have cobbled together
a working example of what I want to do (on a windows box).

The web.xml I configured in a test directory under "webapps" specifies that
the HTTP POST messages received from the producer are to be handled by the

I added a line for the text app in "activemq.xml" ('ow' is the test app

<webAppContext contextPath="/ow" resourceBase="${activemq.base}/webapps/ow"

I created a test script to "insert" messages into the queue which works

The problem I am running into is that it as I continue to insert messages
via REST/HTTP POST, the memory consumption and thread count used by ActiveMQ
continues to rise (It happens when I have timely consumers as well as slow
or non-existent consumers).

When memory consumption gets around 250MB's and the thread count exceeds
5000 (as shown in windows task manager), ActiveMQ crashes and I see this in
the log:

Exception in thread "ActiveMQ Transport Initiator: vm://localhost#3564"
java.lang.OutOfMemoryError: unable to create new native thread

It is as if Jetty is spawning a new thread to handle each HTTP POST and the
thread never dies.

I did look at this page:

and tried <memoryUsage limit="1 mb"/> but that didn't fix the problem
(although I didn't fully understand the implications of the change either).

Does anyone have any ideas?


- Bruce Loth

PS - I included the "test message producer" python script below for what it
is worth.  I created batches of 100 messages and continued to run the script
manually from the command line while watching the memory consumption and
thread count of ActiveMQ in task manager.

def foo():
    import httplib, urllib

    body = "<?xml version='1.0' encoding='UTF-8'?>\n \
    <ROOT>\n \
        [snip: xml deleted to save space]

    headers = {"content-type": "text/xml",
               "content-length": str(len(body))}

    conn = httplib.HTTPConnection("")
    conn.request("POST", "/ow/message/RDRCP_Inbox?type=queue", body,
    response = conn.getresponse()
    print response.status, response.reason
    data =
## end method definition

## Begin test code
count = 0;

while(count < 100):
    # Test with batches of 100 msgs
    count += 1

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message