activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Crashing an AMQ producer in ~12 seconds
Date Sun, 30 Sep 2007 22:51:08 GMT
I'm attaching a pretty straightforward example of some code that  
exhibits a problem that I'm having trouble fixing.  I'm hoping  
someone can either point out my error or at least help me diagnose  
the problem.  Basically, the code simply sends ~5000 messages to a  
broker.  Yes, it's not using a connection pool.  That doesn't seem to  
make any difference and I'm looking for the simplest possible  
example.  After about ~1300 messages, the client runs out of memory  
and dies (jvm default is 64Mb, iirc).

I've tested this with recent AMQ nightly builds or with  
and I get the same result in both cases.  In running this code, I'm  
also seeing several exceptions like this (maybe ~10 by the time I get  
the OOME):

[ActiveMQ Transport: tcp://localhost/] WARN   
org.apache.activemq.ActiveMQConnection  - Async exception with no  
exception listener: Socket closed

Here's the offending code.  Any help would be super.


import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.log4j.Logger;

public class ActiveMQClientDyingExample {

	private static final Logger log = Logger.getLogger 

	public static void main(final String args[]) {

		final String url = "tcp://localhost:61616";
		final String topicName = "test/foo";

		log.debug("Initializing pooled connection factory for JMS to URL: "  
+ url);
		final ActiveMQConnectionFactory normalFactory = new  

		for (int i = 0; i < 5000; i++) {
			if (i % 100 ==0)

			Connection conn = null;
			try {

				conn = normalFactory.createConnection();
				final Session session = conn.createSession(false,  
				final Topic topic = session.createTopic(topicName);
				final MessageProducer producer = session.createProducer(topic);

				final MapMessage m = session.createMapMessage();
				m.setInt("hey", i);


			} catch (JMSException e) {
				log.warn(e.getMessage(), e);
			} finally {
				if (conn != null)
					try {
					} catch (JMSException e) {
						log.warn(e.getMessage(), e);



                                    Philip Jacob

View raw message