activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garima015 <garima_ind...@rediffmail.com>
Subject Re: Performance Issue
Date Tue, 19 Dec 2006 15:05:43 GMT

Thanks for the reply,but it is solved.


Hiram Chirino wrote:
> 
> Best bet is to run it with a profiler to figure out where the hot spot
> is for linux.
> 
> On 12/18/06, garima015 <garima_indiya@rediffmail.com> wrote:
>>
>> I am facing a really bad performance of ActiveMq on linux box.
>> When running on windows 1000 transactions are taking 2 seconds and when
>> running on Linux same are taking 40 sec.
>> Please if anybody can tell me solution to performance issue.
>>
>> Here is the code i am using to send and receive the message.
>>
>> Thanks in advance
>>
>> public class Requestor{
>>         private Session session;
>>         private Destination replyQueue;
>>         private MessageProducer requestProducer;
>>         private MessageConsumer replyConsumer;
>>         Logger logger = null;
>>
>>         /**
>>          * Constructor
>>          */
>>         protected Requestor() {
>>                 super();
>>                 logger =
>> LoggerWrapper.getLogger(this.getClass().getName());
>>         }
>>
>>         /**
>>          * This method will return the object of Requestor
>>          * @param connection, Connection
>>          * @param requestQueueName , String
>>          * @return  Requestor object
>>          * @throws JMSException
>>          * @throws NamingException
>>          */
>>         public static Requestor newRequestor(Connection connection,
>> String
>> requestQueueName)throws JMSException, NamingException {
>>                 Requestor requestor = new Requestor();
>>                 requestor.initialize(connection, requestQueueName);
>>                 return requestor;
>>         }
>>
>>         /**
>>          * This method will initialize the Producer and Consumer on
>> request
>> and reply queue
>>          * @param connection, Connection
>>          * @param requestQueueName , String
>>          * @throws NamingException
>>          * @throws JMSException
>>          */
>>         protected void initialize(Connection connection, String
>> requestQueueName)throws NamingException, JMSException {
>>                 session = connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>>                 Destination requestQueue =
>> session.createQueue(requestQueueName);
>>
>>                 replyQueue = session.createTemporaryQueue();
>>                 requestProducer = session.createProducer(requestQueue);
>>
>> requestProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>>                 replyConsumer = session.createConsumer(replyQueue);
>>                 replyConsumer.receive(10);
>>         }
>>
>>         /**
>>          * This method is used to send the message to queue
>>          * @param message
>>          * @throws JMSException
>>          */
>>         public String send(String message) throws JMSException {
>>                 TextMessage requestMessage = (TextMessage)
>> session.createTextMessage();
>>                 requestMessage.setText(message);
>>                 requestMessage.setJMSReplyTo(replyQueue);
>>                 requestProducer.send(requestMessage);
>>                 return receiveSync();
>>         }
>>
>>         /**
>>          * This method is used to receive the message from the queue
>>          * @return String
>>          * @throws JMSException
>>          */
>>         private String receiveSync() throws JMSException {
>>                 TextMessage replyMessage = null;
>>                 Message msg =  replyConsumer.receive();
>>
>>                 if (msg instanceof TextMessage){
>>                         replyMessage = (TextMessage) msg;
>>                 }
>>                 logger.debug("receive Sync:"+ new Date().getTime());
>>                 return replyMessage.getText();
>>     }
>> }
>>
>> public class Replier implements MessageListener {
>>
>>         private Session session;
>>         Logger logger = null;
>>     Engine engineRef = null;
>>     Transformer transformerRef = null;
>>     MessageConsumer requestConsumer = null;
>>     Destination replyDestination = null;
>>     private static Map destinationMap = new HashMap();
>>     /**
>>      * Constructor
>>      *
>>      */
>>         protected Replier(){
>>         super();
>>                 logger =
>> LoggerWrapper.getLogger(this.getClass().getName());
>>         }
>>
>>         /**
>>          * This will return the instance of replier
>>          * @param connection, Connection
>>          * @param requestQueueName
>>          * @return
>>          * @throws Exception
>>          */
>>         public static Replier newReplier(Connection connection,String
>> requestQueueName ,Engine engine,Transformer transformer)throws Exception
>> {
>>                 Replier replier = new Replier();
>>                 replier.initialize(connection,
>> requestQueueName,engine,transformer);
>>                 return replier;
>>         }
>>
>>         /**
>>          * This method will initilize the consumer on request queue
>>          * @param connection
>>          * @param requestQueueName
>>          * @throws Exception
>>          */
>>         protected void initialize(Connection connection, String
>> requestQueueName, Engine engine,Transformer transformer)throws Exception
>> {
>>                 session = connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>>
>>         // Create the destination (Topic or Queue)
>>                 //Destination requestQueue =
>> session.createQueue(requestQueueName+"?consumer.retroactive=true");
>>                 Destination requestQueue =
>> session.createQueue(requestQueueName);
>>                 requestConsumer = session.createConsumer(requestQueue);
>>                 MessageListener listener = this;
>>                 requestConsumer.setMessageListener(listener);
>>                 engineRef = engine;
>>                 transformerRef = transformer;
>>         }
>>
>>         /**
>>          * This method will be called when ever the message will be
>> placed
>> on Message queue
>>          */
>>         public void onMessage(Message message) {
>>                 try {
>>                         logger.debug("On message:"+ new
>> Date().getTime());
>>                         if ((message instanceof TextMessage) &&
>> (message.getJMSReplyTo() != null)) {
>>                                 TextMessage requestMessage =
>> (TextMessage)
>> message;
>>                                 String contents =
>> requestMessage.getText();
>>
>>                                 Object obj =
>> transformerRef.transform(contents);
>>                 engineRef.process(obj);
>>                 contents = (String)transformerRef.transform(obj);
>>
>>                 if(null ==
>> destinationMap.get(message.getJMSReplyTo().hashCode())){
>>                    destinationMap.put(message.getJMSReplyTo().hashCode(),
>> message.getJMSReplyTo());
>>                    replyDestination = message.getJMSReplyTo();
>>                    logger.info("In new");
>>                 }else{
>>                 replyDestination = (Destination)
>> destinationMap.get(message.getJMSReplyTo().hashCode());
>>                 logger.info("in already");
>>                 }
>>
>>      MessageProducer replyProducer =
>> session.createProducer(replyDestination);
>>                                 TextMessage replyMessage =
>> session.createTextMessage();
>>                                 replyMessage.setText(contents);
>>
>> replyMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());
>>                                 replyProducer.send(replyMessage);
>>                         }
>>                 }catch (JMSException ex) {
>>                         logger.fatal("Failing while reading the message
>> from
>> queue"+ex.getMessage(),ex);
>>                 }catch (Exception e) {
>>                         logger.fatal("Failing while transforming the
>> message"+e.getMessage(),e);
>>                 }
>>         }
>>
>> }
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Performance-Issue-tf2841698.html#a7934436
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Regards,
> Hiram
> 
> Blog: http://hiramchirino.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Performance-Issue-tf2841698.html#a7948596
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message