activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rikky (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMQ-3538) request-response performance is poor when the client and broker lie in different machine
Date Thu, 13 Oct 2011 09:15:12 GMT

    [ https://issues.apache.org/jira/browse/AMQ-3538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13126448#comment-13126448
] 

rikky commented on AMQ-3538:
----------------------------

The unit tests are as below:

Service Code:
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;

public class Server
{

	public static void main(String[] args) throws JMSException
	{
		String url ="tcp://192.168.230.253:61616";
		ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
		Connection conn = factory.createConnection();
		conn.start();
		final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
		Destination dst = session.createQueue("tmp");
		MessageConsumer consumer = session.createConsumer(dst);
		while(true)
		{
			TextMessage reqMsg = (TextMessage) consumer.receive();
			Destination reply = reqMsg.getJMSReplyTo();
			MessageProducer producer = session.createProducer(reply);
			TextMessage replyMsg = session.createTextMessage(reqMsg.getText());
			producer.send(replyMsg);
			producer.close();
		}		
	}

}

Client Code:
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueRequestor;
import javax.jms.QueueSession;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;

public class Client
{

	public static void main(String[] args) throws JMSException
	{
		String url ="tcp://192.168.230.253:61616";
		ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
		Connection conn = factory.createConnection();
		conn.start();
		
		Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
		Queue dst = session.createQueue("tmp");
		QueueRequestor request = new QueueRequestor((QueueSession) session, dst);
		Message msg = session.createTextMessage("gogo");
		
		try
		{
			long s = System.currentTimeMillis();
			for (int i = 0; i < 10; i++)
			{
				Message resp = request.request(msg);
			}
			long e = System.currentTimeMillis();
			System.out.println( e - s);
		}
		finally
		{
			session.close();
		}
		
		conn.close();
	}

}

It took about 4000ms to finish the client code, but if i change the sending message size to
30k, it took only 300ms.By the way, i just used the default Broker configuration.
Thanks.
                
> request-response performance is poor when the client and broker lie in different machine
> ----------------------------------------------------------------------------------------
>
>                 Key: AMQ-3538
>                 URL: https://issues.apache.org/jira/browse/AMQ-3538
>             Project: ActiveMQ
>          Issue Type: Improvement
>          Components: Broker
>    Affects Versions: 5.4.2, 5.5.0
>         Environment: JDK 1.6, windows 2008 server.
>            Reporter: rikky
>
> for example:		
> Message msg = session.createTextMessage("gogogo");		
> 		try
> 		{
> 			long s = System.currentTimeMillis();
> 			for (int i = 0; i < 100; i++)
> 			{
> 				Message resp = request.request(msg);
> 			}
> 			long e = System.currentTimeMillis();
> 			System.out.println( e - s);
> 		}
> 		finally
> 		{
> 			session.close();
> 		}
> execute the above codes, the performance is very poor, can only handle 2-3messages/sec.
> but if i increase the message size to about 20k, then the performance increase incredibly,
can handle 50 messages/sec!
> maybe the broker use some strategy to block the outgoing message,if that is true, any
configuration to change that strategy?
> Thanks.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message