activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jigar Naik <jigarn...@interactcrm.com>
Subject Producer stops producing messages after producing 1542 messages.
Date Sat, 30 Aug 2008 09:15:00 GMT

hi 

i am facing problem with producer, 

My producer stops producing messages after producing 1542 messages on active
mq 

bellow is my output after running producer thread 

OUTPUT
Message Sent : Hello This is a text message on active MQ : 1542
Exception in thread "ActiveMQ Transport: tcp://localhost/127.0.0.1:61616"
java.lang.OutOfMemoryError: Java heap space
Exception in thread "InactivityMonitor ReadCheck"
java.lang.OutOfMemoryError: Java heap space

What could be the possible reason for this error..

bellow is my producer code...
Producer.java
---------------------
package org.icrm;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;


public class Producer {
	private MessageProducer 	producer;
	ActiveMQConnectionFactory 	connectionFactory;
	Connection 					connection;
	Session 					session;
	Destination 				destination;
	
	public static void main(String[] args) {
		Producer p = new Producer();
		
		for(int i=0;i<100000;i++){
			p.sendMessageToActiveMQ("Hello This is a text message on active MQ : " +
i, "TestQueue");
		}
		
	}
	/**
	 * Send Message to ActiveMQ
	 * @param message
	 * @param queueName
	 */
	public void sendMessageToActiveMQ(String message,String queueName){
		try {
			connectionFactory 	= new
ActiveMQConnectionFactory("tcp://localhost:61616");
			connection 			= connectionFactory.createConnection();
			connection.start();
			session 			= connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
			destination 		= session.createQueue(queueName);
			this.producer 		= session.createProducer(destination);
			this.producer.setDeliveryMode(DeliveryMode.PERSISTENT);
			TextMessage textMessage = session.createTextMessage();
			textMessage.setText(message);
			this.producer.send(textMessage);
			System.out.println("Message Sent : " + message);
		} catch (JMSException e) {
			e.printStackTrace();
		} catch (Exception e){
			e.printStackTrace();
		}finally{
			producer 			= null;
			connectionFactory 	= null;
			connection 			= null;
			session 			= null;
			destination 		        = null;
		}

	}
}

-- 
View this message in context: http://www.nabble.com/Producer-stops-producing-messages-after-producing-1542-messages.-tp19231685p19231685.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message