activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rousseau <steve.co...@excite.com>
Subject NMS and ActiveMQ latency
Date Wed, 06 Dec 2006 03:54:24 GMT

Just started looking at using C#NMS implementation and ActiveMQ 4.0.2, and am
having latency issues when the broker is on a different machine.

The C# code (more or less the same as the example) is given below. When I
run ./activemq on the same machine I get almost 0 latency reported, but when
I run ./activemq on a different machine (or different VM on the same box) I
get latency figures around 200ms. Am I doing something wrong?

thanks for your help
/Steve



Code:

   public partial class Form1 : Form
    {
        HiPerfTimer timer;
        IConnectionFactory factory;
        IConnection connection;
        ISession session;
        IDestination destination;
        IMessageConsumer consumer;
        IMessageProducer producer;

        public Form1()
        {
            InitializeComponent();

            //Initialise MQ adapter
            factory = new ConnectionFactory(new
Uri("tcp://stevefedora:61616"));
            connection = factory.CreateConnection();
            session = connection.CreateSession();
            destination = session.GetQueue("Dog");

            consumer = session.CreateConsumer(destination);
            producer = session.CreateProducer(destination);
            producer.Persistent = false;

            timer = new HiPerfTimer();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ITextMessage request;
            ActiveMQTextMessage message;

            request = session.CreateTextMessage("Hello!");
            request.NMSCorrelationID = "abc";
            request.Properties["Title"] = "Hello World";
            request.Properties["Text"] = "To be or not to be.";

            for (int i = 0; i < 10; i++)
            {

                //Start timing
                timer.Start();

                //Create and send request
                producer.Send(request);

                //recieve request
                message = (ActiveMQTextMessage)consumer.Receive();

                //stop timing
                timer.Stop();

                //print result
                this.listBox1.Items.Add("[" + timer.Duration + " ms] " +
                    "Summat:" + message.NMSMessageId + "/" + message.Text +
" " + message.Properties);
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs
e)
        {
            consumer.Close();
            session.Close();
            connection.Close();
            
        }
    }
-- 
View this message in context: http://www.nabble.com/NMS-and-ActiveMQ-latency-tf2765978.html#a7713166
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message