activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vinod Venkatraman <vinod...@gmail.com>
Subject Re: ActiveMQ Sending Performance
Date Mon, 19 Nov 2007 09:47:13 GMT

Ur sender code looks fine to me, are u sure ur messages are not being
persisted by ActiveMQ. 
Persistence can slow down send considerably. Check ur ActiveMQ config file
for persistence.

http://activemq.apache.org/persistence.html


andriy_heikal wrote:
> 
> Hi Guys,
> 
> I'm newbie on ActiveMQ. I've been trying to develop JMS using ActiveMQ. I
> create 2 file
> first as sender :
> package tutorial.jms;
> 
> import java.util.Date;
> 
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.MessageProducer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> 
> import org.apache.activemq.ActiveMQConnection;
> import org.apache.activemq.ActiveMQConnectionFactory;
> 
> public class HelloQueueSender {
>     public static void main(String[] args) throws JMSException {
>         ConnectionFactory factory = new ActiveMQConnectionFactory(
>                 ActiveMQConnection.DEFAULT_USER,
>                 ActiveMQConnection.DEFAULT_PASSWORD,
>                 ActiveMQConnection.DEFAULT_BROKER_URL);
>         Date mulai = new Date();
>         System.out.println("Start Sending : " + mulai);
> 
>         Connection conn = factory.createConnection();
> 
>         Session sess = conn.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> 
>         Queue destination = sess.createQueue("test");
> 
>         MessageProducer prod = sess.createProducer(destination);
>         TextMessage msg = sess.createTextMessage();
>         msg.setText("Hello JMS");
> 
>         
>         int i = 1;
>         while (i<=5000){
>         	prod.send(msg);
>         	i++;
>         }
> 
>         prod.close();
>         sess.close();
>         conn.close();
>         Date selesai = new Date();
>         System.out.println("End Sending : " + selesai);
>     }
> }
> 
> 
> second is for receiver :
> package tutorial.jms;
> 
> import javax.jms.Connection;
> import javax.jms.ConnectionFactory;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageConsumer;
> import javax.jms.Queue;
> import javax.jms.Session;
> import javax.jms.TextMessage;
> 
> import org.apache.activemq.ActiveMQConnection;
> import org.apache.activemq.ActiveMQConnectionFactory;
> 
> public class HelloQueueReceiver {
>     public static void main(String[] args) throws Exception {
>         ConnectionFactory factory = new ActiveMQConnectionFactory(
>                 ActiveMQConnection.DEFAULT_USER,
>                 ActiveMQConnection.DEFAULT_PASSWORD,
>                 ActiveMQConnection.DEFAULT_BROKER_URL);
> 
>         Date mulai = new Date();
>         System.out.println("Start Receiving : " + mulai);
>         Connection conn = factory.createConnection();
> 
>         Session sess = conn.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
> 
>         Queue destination = sess.createQueue("test");
> 
>         MessageConsumer consumer = sess.createConsumer(destination);
>         conn.start();
>         int counter = 1;
>         while(true) {           
>             Message msg = consumer.receive(1000);
>             if (msg == null) break;
>             if (msg instanceof TextMessage) {
>                 TextMessage txtmsg = (TextMessage) msg;
>             }
>         }
> 
>         consumer.close();
>         sess.close();
>         conn.close();
>         Date selesai = new Date();
>         System.out.println("End Receiving : " + selesai);
>     }
> } 
> =======================================================
> What my concern is sender performance, for 5000 messages takes 135sec or
> 37msg/sec but receiver performance is very good at 2500msg/sec. My
> question is why it so be different, I guess my code is wrong.
> Can anybody help me solved this problem?
> 
> Regards,
> 
> Heikal
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-Sending-Performance-tf4833383s2354.html#a13830613
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message