1 Reply Latest reply on Apr 26, 2009 6:16 PM by gaohoward

    Sending a message to a queue is slow sometimes.

      Hi,

      I am experiencing periodic performance issues when sending an object to a message queue on jboss 5 jmessaging.

      Normally this operation takes 10 ms but sometimes(1%) I see 5+ seconds below is the code.

      I have ruled out Garbage collection as the cause. Any advice on the code below specifically on the message send line and why it would be a resource problem - any queue sizing I need to be aware of?

      I use mysql as the persistence layer to a localhost database - any connection pool sizing I should be aware of ( I use a connection pool of min 5 / max 20 ).

      Any advice on performance please ?

      Thanks,
      Colm

      public final static void sendObjectToQueue(String queueName,
       EPOSBatchMessage messageObject) {
       long startTime = System.currentTimeMillis();
       QueueConnection conn = null;
       QueueSession session = null;
       Queue que = null;
       InitialContext iniCtx = null;
       QueueConnectionFactory qcf = null;
       Object tmp = null;
       QueueSender send = null;
       try {
       log.debug("PERFORMANCE: (sendObjectToQueue): size of message: " + messageObject.toString().length() + " - " + (System.currentTimeMillis() - startTime ) + "(ms)");
      
       iniCtx = new InitialContext();
       tmp = iniCtx.lookup("ConnectionFactory");
       qcf = (QueueConnectionFactory) tmp;
       log.debug("PERFORMANCE: (sendObjectToQueue): About to create connection: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       conn = qcf.createQueueConnection();
       log.debug("PERFORMANCE: (sendObjectToQueue): Connection Created: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       que = (Queue) iniCtx.lookup(queueName);
       log.debug("PERFORMANCE: (sendObjectToQueue): Queue lookup succeeded: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       session = conn.createQueueSession(false,
       QueueSession.AUTO_ACKNOWLEDGE);
       log.debug("PERFORMANCE: (sendObjectToQueue): Session Created: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       send = session.createSender(que);
       log.debug("PERFORMANCE: (sendObjectToQueue): Sender Created: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       ObjectMessage om = session.createObjectMessage();
       om.setObject(messageObject);
       log.debug("PERFORMANCE: (sendObjectToQueue): Message Created: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       send.send(om); // <----- this is where the slow down is occuring
       log.debug("PERFORMANCE: (sendObjectToQueue): Message Sent: " + (System.currentTimeMillis() - startTime ) + "(ms)");
       log.info("sendMessage, sent object = " + om
       + " sent queue = " + queueName);
       if(send!=null){ send.close(); }
       if(conn!=null){conn.close();}
       if(session!=null){session.close();}
       }catch (Exception e){
       log.error("In sendObjectToQueue: caught exception: " + e);
       e.printStackTrace();
       }
       long endTime = System.currentTimeMillis();
       long time = endTime - startTime;
       log.debug("PERFORMANCE: (sendObjectToQueue" + queueName + " , " + messageObject + "): Time Taken: " + time + "(ms)");