2

Good Morning,

I'm a new user of JMS technology and particularly with ActiveMQ solution. I'm having some problems with the performance of my application. Specifically, i'm developing a 24x7 application. We are using MessageListener for all consumers. My specifications:

  • I'm running my application in a VMWare Virtual Machine: Single CPU, 2GB RAM, 20GB of local disk. SO: Win7 (32bits)
  • Java SE 1.6.35 with standar configuration
  • ActiveMQ 5.5.1 without any tunning modification. Specifically, i'm using producers with non-persistence delivery mode (just with queues), and asynchronous consumers. Both consumers and producers, use different sessions from the same connection.

This is my application:

**Producer code - main class -**

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url+"?jms.prefetchPolicy.all=1"); 
Connection connection = connectionFactory.createConnection(); 
connection.start(); 
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); 
Destination destination = session.createQueue(subject); 
MessageProducer producer = session.createProducer(destination); 
while (true) 
{ 
        Event evento = new Event("Event1"); 
        ObjectMessage msj = session.createObjectMessage(event); 
        msj5.setJMSType(msj5.getClass().getSimpleName()); 
        msj5.setJMSReplyTo(destination); 
        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); 
        producer.send(msj5, DeliveryMode.NON_PERSISTENT, 5, 0); 
        Thread.sleep(1000); 
} 


**Consumer code -main class-**

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url+"?jms.prefetchPolicy.all=1"); 
Connection connection = connectionFactory.createConnection(); 
session = connection.createSession(true, 0); 
Destination destination = session.createQueue(subject); 
MessageConsumer consumer = session.createConsumer(destination); 
//This is my listener 
Escuchador escuchador = new Escuchador(); 
consumer.setMessageListener(escuchador); 
connection.start(); 


**Listener code**

public void onMessage(Message message) 
{ 
    if (message instanceof ObjectMessage) 
    { 
       try 
    { 
           ObjectMessage msj = (ObjectMessage) message; 
           Object obj = msj.getObject(); 
           if (obj instanceof Event) 
           { 
             Event event = (Event) obj; 
             System.out.println("Event: " + event.toString()); 
           } 
        } 
    catch (JMSException e) 
    { 
      System.out.println("Error at ObjectMessage"); 
    } 
    } 
}

Both consumer and producer was executed from a main class that create two instances of them (one per each). Then, I made a runnable jar file and I run it from the JProfiler tool. In the results appears "ActiveMQObjectMessage" and "MessageId" references (in Recorded objects view), and "getObject" and "createObjectMessage" (in allocation hot spots). When I step into each of them (seeing his incomming and outcomming references) I allways achieve "activeMQSession" object.

The key it's that I can't close my connection or session object because I wan't to stop my 24x7 service. My question is: Is it possible?, or I need to close the connection for improve the performance?

Thanks in advance

Regards

0 Answers0