[activemq-user] Memory usage with a very simple topic send test case

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[activemq-user] Memory usage with a very simple topic send test case

CLAYTON, Neil , FM
Hullo All!

I'm attempting to do something very simple.
Set up a broker, and send messages to a queue as fast as possible, while
monitoring the memory that is used.
As I understand it, if I don't use any persistence mechanism, and send
non-durable messages, then virtually no memory should be consumed. However;
that's not what I see.

    public void testActiveMQMemoryUsage() throws Exception {
        ActiveMQ activeMQ = new ActiveMQ();
        activeMQ.setPersistenceAdapter(new VMPersistenceAdapter());
        activeMQ.start();

        // Get a connection/topic, start firing messages at it
        TopicConnectionFactory factory = getConnectionFactory();
        Connection connection = factory.createConnection();

        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        Topic topic = session.createTopic("t1");
        connection.start();

        int msgCount = 0;
        Runtime runtime = Runtime.getRuntime();

        while (true) {
            MessageProducer producer = session.createProducer(topic);
            TextMessage message = session.createTextMessage();
            message.setText("The time is now " +
System.currentTimeMillis());
            producer.send(message, DeliveryMode.NON_PERSISTENT, 1, 500);
            producer.close();

            msgCount++;
            if (msgCount % 10000 == 0) {
                monitorMemory();
            }
        }
    }
    private void monitorMemory() throws InterruptedException, JMSException {
        Runtime runtime = Runtime.getRuntime();
        System.out.println("Free: " + runtime.freeMemory() / 1024 / 1024 +
"MB, total: " + runtime.totalMemory() / 1024
            / 1024 + "MB, max: " + runtime.maxMemory() / 1024 / 1024 +
"MB");
        // Thread.sleep(1000);
    }

The class ActiveMQ is in this case a subclass of BrokerImpl.
What I see when I run this, is as follows:
Free: 2MB, total: 6MB, max: 63MB
Free: 2MB, total: 10MB, max: 63MB
Free: 5MB, total: 17MB, max: 63MB
Free: 2MB, total: 17MB, max: 63MB
Free: 9MB, total: 30MB, max: 63MB
Free: 4MB, total: 30MB, max: 63MB

If I leave it long enough, an exception is thrown (see below).
In case you're wondering - I am creating/closing the message producer in an
effort to emulate what the JmsTemplate does in Spring.

Am I doing something silly?  The broker URL in use is tcp://localhost:12345.

Regards,
Neil Clayton


2005-06-17 15:14:18.096 [TcpTransportChannel:
Socket[addr=/127.0.0.1,port=4129,localport=12121]] WARN:
impl.BrokerClientImpl - caught exception consuming packet:
ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage{ , jmsMessageID = null,
bodyAsBytes = org.activemq.io.util.ByteArray@15196c8, readOnlyMessage =
false, jmsClientID = 'null' , jmsCorrelationID = 'null' , jmsDestination =
null, jmsReplyTo = null, jmsDeliveryMode = 1, jmsRedelivered = false,
jmsType = 'null' , jmsExpiration = 1119017658596, jmsPriority = 1,
jmsTimestamp = 1119017658096, properties = null, readOnlyProperties = false,
entryBrokerName = 'ID:lonmw86885-4128-1119017632346-0:0' , entryClusterName
= 'default' , consumerNos = null, transactionId = 'null' , xaTransacted =
false, consumerIdentifer = 'null' , messageConsumed = false,
transientConsumed = false, sequenceNumber = 0, deliveryCount = 1,
dispatchedFromDLQ = false, messageAcknowledge = null, jmsMessageIdentity =
null, producerKey = null }, text = The time is now 1119017658096
javax.jms.JMSException: No destination specified for the Message
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:279)
        at
org.activemq.broker.impl.BrokerContainerImpl.sendMessage(BrokerContainerImpl
.java:462)
        at
org.activemq.broker.impl.BrokerConnectorImpl.sendMessage(BrokerConnectorImpl
.java:271)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeActiveMQMessage(BrokerClien
tImpl.java:696)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:309)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:374)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:368)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
310)
        at java.lang.Thread.run(Thread.java:534)
2005-06-17 15:14:18.112 [TcpTransportChannel:
Socket[addr=/127.0.0.1,port=4129,localport=12121]] WARN:
impl.BrokerClientImpl - caught exception consuming packet:
ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage{ , jmsMessageID = null,
bodyAsBytes = org.activemq.io.util.ByteArray@cf7246, readOnlyMessage =
false, jmsClientID = 'null' , jmsCorrelationID = 'null' , jmsDestination =
null, jmsReplyTo = null, jmsDeliveryMode = 1, jmsRedelivered = false,
jmsType = 'null' , jmsExpiration = 1119017658612, jmsPriority = 1,
jmsTimestamp = 1119017658112, properties = null, readOnlyProperties = false,
entryBrokerName = 'ID:lonmw86885-4128-1119017632346-0:0' , entryClusterName
= 'default' , consumerNos = null, transactionId = 'null' , xaTransacted =
false, consumerIdentifer = 'null' , messageConsumed = false,
transientConsumed = false, sequenceNumber = 0, deliveryCount = 1,
dispatchedFromDLQ = false, messageAcknowledge = null, jmsMessageIdentity =
null, producerKey = null }, text = The time is now 1119017658112
javax.jms.JMSException: No destination specified for the Message
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:279)
        at
org.activemq.broker.impl.BrokerContainerImpl.sendMessage(BrokerContainerImpl
.java:462)
        at
org.activemq.broker.impl.BrokerConnectorImpl.sendMessage(BrokerConnectorImpl
.java:271)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeActiveMQMessage(BrokerClien
tImpl.java:696)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:309)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:374)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:368)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
310)
        at java.lang.Thread.run(Thread.java:534)
2005-06-17 15:14:18.112 [TcpTransportChannel:
Socket[addr=/127.0.0.1,port=4129,localport=12121]] WARN:
impl.BrokerClientImpl - caught exception consuming packet:
ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage{ , jmsMessageID = null,
bodyAsBytes = org.activemq.io.util.ByteArray@11f108a, readOnlyMessage =
false, jmsClientID = 'null' , jmsCorrelationID = 'null' , jmsDestination =
null, jmsReplyTo = null, jmsDeliveryMode = 1, jmsRedelivered = false,
jmsType = 'null' , jmsExpiration = 1119017658612, jmsPriority = 1,
jmsTimestamp = 1119017658112, properties = null, readOnlyProperties = false,
entryBrokerName = 'ID:lonmw86885-4128-1119017632346-0:0' , entryClusterName
= 'default' , consumerNos = null, transactionId = 'null' , xaTransacted =
false, consumerIdentifer = 'null' , messageConsumed = false,
transientConsumed = false, sequenceNumber = 0, deliveryCount = 1,
dispatchedFromDLQ = false, messageAcknowledge = null, jmsMessageIdentity =
null, producerKey = ID:lonmw86885-4128-1119017632346-65543: }, text = The
time is now 1119017658112
javax.jms.JMSException: No destination specified for the Message
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:279)
        at
org.activemq.broker.impl.BrokerContainerImpl.sendMessage(BrokerContainerImpl
.java:462)
        at
org.activemq.broker.impl.BrokerConnectorImpl.sendMessage(BrokerConnectorImpl
.java:271)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeActiveMQMessage(BrokerClien
tImpl.java:696)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:309)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:374)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:368)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
310)
        at java.lang.Thread.run(Thread.java:534)
2005-06-17 15:14:18.112 [TcpTransportChannel:
Socket[addr=/127.0.0.1,port=4129,localport=12121]] WARN:
impl.BrokerClientImpl - caught exception consuming packet:
ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage{ , jmsMessageID = null,
bodyAsBytes = org.activemq.io.util.ByteArray@15ab524, readOnlyMessage =
false, jmsClientID = 'ID:lonmw86885-4128-1119017632346-65544:' ,
jmsCorrelationID = 'null' , jmsDestination = null, jmsReplyTo = null,
jmsDeliveryMode = 1, jmsRedelivered = false, jmsType = 'null' ,
jmsExpiration = 1119017658612, jmsPriority = 1, jmsTimestamp =
1119017658112, properties = null, readOnlyProperties = false,
entryBrokerName = 'ID:lonmw86885-4128-1119017632346-0:0' , entryClusterName
= 'default' , consumerNos = null, transactionId = 'null' , xaTransacted =
false, consumerIdentifer = 'null' , messageConsumed = false,
transientConsumed = false, sequenceNumber = 0, deliveryCount = 1,
dispatchedFromDLQ = false, messageAcknowledge = null, jmsMessageIdentity =
null, producerKey = ID:lonmw86885-4128-1119017632346-65544: }, text = The
time is now 1119017658112
javax.jms.JMSException: No destination specified for the Message
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:279)
        at
org.activemq.broker.impl.BrokerContainerImpl.sendMessage(BrokerContainerImpl
.java:462)
        at
org.activemq.broker.impl.BrokerConnectorImpl.sendMessage(BrokerConnectorImpl
.java:271)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeActiveMQMessage(BrokerClien
tImpl.java:696)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:309)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:374)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:368)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
310)
        at java.lang.Thread.run(Thread.java:534)
2005-06-17 15:14:18.112 [TcpTransportChannel:
Socket[addr=/127.0.0.1,port=4129,localport=12121]] WARN:
impl.BrokerClientImpl - caught exception consuming packet:
ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage{ , jmsMessageID = null,
bodyAsBytes = org.activemq.io.util.ByteArray@15800aa, readOnlyMessage =
false, jmsClientID = 'ID:lonmw86885-4128-1119017632346-65544:' ,
jmsCorrelationID = 'null' , jmsDestination = null, jmsReplyTo = null,
jmsDeliveryMode = 1, jmsRedelivered = false, jmsType = 'null' ,
jmsExpiration = 1119017658612, jmsPriority = 1, jmsTimestamp =
1119017658112, properties = null, readOnlyProperties = false,
entryBrokerName = 'ID:lonmw86885-4128-1119017632346-0:0' , entryClusterName
= 'default' , consumerNos = null, transactionId = 'null' , xaTransacted =
false, consumerIdentifer = 'null' , messageConsumed = false,
transientConsumed = false, sequenceNumber = 0, deliveryCount = 1,
dispatchedFromDLQ = false, messageAcknowledge = null, jmsMessageIdentity =
null, producerKey = ID:lonmw86885-4128-1119017632346-65545: }, text = The
time is now 1119017658112
javax.jms.JMSException: No destination specified for the Message
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:279)
        at
org.activemq.broker.impl.BrokerContainerImpl.sendMessage(BrokerContainerImpl
.java:462)
        at
org.activemq.broker.impl.BrokerConnectorImpl.sendMessage(BrokerConnectorImpl
.java:271)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeActiveMQMessage(BrokerClien
tImpl.java:696)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:309)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:374)
        at
org.activemq.transport.TransportChannelSupport.doConsumePacket(TransportChan
nelSupport.java:368)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
310)
        at java.lang.Thread.run(Thread.java:534)
java.lang.ClassCastException: java.lang.String
        at
org.activemq.io.impl.ActiveMQMessageReader.buildPacket(ActiveMQMessageReader
.java:107)
        at
org.activemq.io.impl.DefaultWireFormat.readPacket(DefaultWireFormat.java:129
)
        at
org.activemq.io.impl.AbstractDefaultWireFormat.readPacket(AbstractDefaultWir
eFormat.java:189)
        at
org.activemq.io.impl.AbstractDefaultWireFormat.readPacket(AbstractDefaultWir
eFormat.java:174)
        at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:
308)
        at java.lang.Thread.run(Thread.java:534)


***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312.  Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.                                      
Authorised and regulated by the Financial Services Authority    
 
This e-mail message is confidential and for use by the                      
addressee only. If the message is received by anyone other            
than the addressee, please return the message to the sender          
by replying to it and then delete the message from your                    
computer. Internet e-mails are not necessarily secure. The              
Royal Bank of Scotland plc does not accept responsibility for          
changes made to this message after it was sent.                              
                                                                                                       
Whilst all reasonable care has been taken to avoid the                  
transmission of viruses, it is the responsibility of the recipient to        
ensure that the onward transmission, opening or use of this            
message and any attachments will not adversely affect its              
systems or data.  No responsibility is accepted by The Royal          
Bank of Scotland plc in this regard and the recipient should carry  
out such virus and other checks as it considers appropriate.          
                                                                                                               Visit our websites at:                                                                          
http://www.rbs.co.uk/CBFM                                                       
http://www.rbsmarkets.com                                                         
                                                                                                       ********************************************************************************

Loading...