|
From: Priest, M. <mp...@3e...> - 2005-04-28 13:00:36
|
Try looping and sending a few thousand mesages and taking an average.
Sending just one message may incur some overhead. I have used OpenJMS and
have not seen that kind of latency in my publishing. I have been able to
publish around 50 messages per second using OpenJMS with just my laptop.
-----Original Message-----
From: Vel Pandian [mailto:vel...@gm...]
Sent: Thursday, April 28, 2005 8:21 AM
To: ope...@li...
Subject: [openjms-user] to publish a object msg it takes 0.5sec
Hi
I am using open JMS
I had checked the time difference in the execution of the publishing a
msg it took around 500 milli seconds. is there any way to reduce it,
or any other suggestion
plzz help
thnx Vel Pandian
here is the following code just copy paste and run it works as the msg
consumer and producer
import java.util.Hashtable;
import javax.jms.*;
import javax.naming.*;
public class MessageSink implements MessageListener
{
private TopicConnection topicConnection;
private TopicSession topicSession;
private Topic topic;
static private TopicSubscriber topicSubscriber;
//static private Logger myLogger;
TopicPublisher topicPublisher;
MessageSink()
{
try
{
// create a JNDI context
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
//properties.put(Context.PROVIDER_URL, "tcp://localhost:3035/");
Context context = new InitialContext(properties);
// retrieve topic connection factory
TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) context
.lookup("JmsTopicConnectionFactory");
// create a queue connection
topicConnection =
topicConnectionFactory.createTopicConnection();
// create a topic session
// set transactions to false and set auto acknowledgement
of receipt of messages
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
// retrieve queue
topic = (Topic) context.lookup("topic1");
// create a queue recevier and associate to the retrieved queue
topicSubscriber = topicSession.createSubscriber(topic);
topicPublisher = topicSession.createPublisher(topic);
// associate message listener
topicSubscriber.setMessageListener(this);
// start delivery of incoming messages
topicConnection.start();
} catch (NamingException e)
{
e.printStackTrace();
} catch (JMSException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
MessageSink messageSink = new MessageSink();
long startTime = System.currentTimeMillis();
messageSink.publish();
System.out.println("Total time take " +
(System.currentTimeMillis() - startTime));
}
public void publish()
{
System.out.println("listening");
try {
long startTime = System.currentTimeMillis();
ObjectMessage msg = topicSession.createObjectMessage();
System.out.println("time for creating objectmessage " +
(System.currentTimeMillis() - startTime));
msg.setObject("vel pandian");
startTime = System.currentTimeMillis();
topicPublisher.publish(msg);
System.out.println("topicPublisher " +
(System.currentTimeMillis() - startTime));
} catch(Exception e) {
e.printStackTrace();
}
}
// process incoming queue messages
public void onMessage(Message message)
{
System.out.println("onMessage Called .... ");
try
{
String messageText = null;
if (message instanceof ObjectMessage)
{
ObjectMessage objectMessage = (ObjectMessage) message;
System.out.println(objectMessage.getObject());
}
} catch (JMSException e)
{
e.printStackTrace();
}
}
}
-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
_______________________________________________
openjms-user mailing list
ope...@li...
https://lists.sourceforge.net/lists/listinfo/openjms-user
|