[jboss-user] [JBoss Messaging] - Piling thread count when it polls the queue.

apk2072 do-not-reply at jboss.com
Wed May 30 10:28:57 EDT 2007


For every 10 seconds my code calls the below method to poll for new messages, but the problem is, JBoss messaging implementation is internally creating a new thread whenever it executes the session.createConsumer(queue) statement. And thread count grows continuously as it polls, after some time it ends up with Out of Memory error.

Is it a bug in the JBM implementation or I am not doing it correctly? Please advice.



  |      public String pollForNewMsg() throws Exception
  |      {
  |                InitialContext ic = new InitialContext();
  | 	       ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
  | 					Connection _jmsConn = cf.createConnection();
  | 	       Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); 
  | 	       Queue queue = (Queue)ic.lookup(queueName);
  | 	            javax.jms.MessageConsumer consumer = session.createConsumer(queue);
  | 	       conn.start();
  |                TextMessage msg = (TextMessage)consumer.receive(10);
  |                String text = msg.getText();
  |                     
  |                consumer.close();
  |                conn.close();
  | 
  |                return text;
  |       }
  | 


-APK.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049739#4049739

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049739



More information about the jboss-user mailing list