Return-Path: Delivered-To: apmail-geronimo-activemq-dev-archive@www.apache.org Received: (qmail 33886 invoked from network); 19 Dec 2006 14:25:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Dec 2006 14:25:25 -0000 Received: (qmail 8851 invoked by uid 500); 19 Dec 2006 14:25:32 -0000 Delivered-To: apmail-geronimo-activemq-dev-archive@geronimo.apache.org Received: (qmail 8808 invoked by uid 500); 19 Dec 2006 14:25:32 -0000 Mailing-List: contact activemq-dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-dev@geronimo.apache.org Received: (qmail 8799 invoked by uid 99); 19 Dec 2006 14:25:32 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Dec 2006 06:25:32 -0800 X-ASF-Spam-Status: No, hits=0.8 required=10.0 tests=INFO_TLD,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of chirino@gmail.com designates 64.233.184.238 as permitted sender) Received: from [64.233.184.238] (HELO wr-out-0506.google.com) (64.233.184.238) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Dec 2006 06:25:22 -0800 Received: by wr-out-0506.google.com with SMTP id i31so819156wra for ; Tue, 19 Dec 2006 06:25:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=OCg1zzPzHCUpOQST9dwO97itnfZ4FTwNY+ETIdfQpzgRWQ712saUq5WkIpRvHagbVWZKfr1ggAB/carLDpAEvrICiWk05F/CBTowg4xfmVcnszmVeAhFOXoQNxc2RiSO9fhIH1NOevbf6/hnoei1Fl7i19ROuWUoicKP2PrWSRk= Received: by 10.90.69.8 with SMTP id r8mr5411639aga.1166538301257; Tue, 19 Dec 2006 06:25:01 -0800 (PST) Received: by 10.90.95.3 with HTTP; Tue, 19 Dec 2006 06:25:01 -0800 (PST) Message-ID: Date: Tue, 19 Dec 2006 09:25:01 -0500 From: "Hiram Chirino" Sender: chirino@gmail.com To: activemq-dev@geronimo.apache.org Subject: Re: Performance Issue In-Reply-To: <7934436.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <7934436.post@talk.nabble.com> X-Google-Sender-Auth: 04a743523e7ff674 X-Virus-Checked: Checked by ClamAV on apache.org Best bet is to run it with a profiler to figure out where the hot spot is for linux. On 12/18/06, garima015 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