Memory consumed is growing slowly with a time... over 100 MB in one day and it never comes back... there must be something wrong with my code below? do I need message.acknowledge() or something?
TIA, Milan ----- Original Message ---- From: Gary Tully <gary.tu...@gmail.com> To: users@activemq.apache.org Sent: Wed, March 24, 2010 11:08:18 AM Subject: Re: OutOfMemoryException in consumer try reducing the prefetch, you may be getting up to 1000 messages accumulated on your consumer: http://activemq.apache.org/what-is-the-prefetch-limit-for.html Also have a read of: http://activemq.apache.org/javalangoutofmemory.html On 24 March 2010 09:37, Milan Tomic <tomicmi...@yahoo.com> wrote: > Is this consumer code OK? Sometimes I got OutOfMemoryException and I can't > find what resources I am not releasing... > > while (true) { > try { > Connection conn = oraPC.getConnection(); > Statement stmt = null; > try { > while ((message = mq_consumer.receive(10)) != null) { > if (message instanceof ObjectMessage) { > if (stmt == null) > stmt = conn.createStatement(); > ObjectMessage msg = (ObjectMessage)message; > String insert = getInsert(msg); > stmt.addBatch(insert); > sql += "\r\n"+insert; > } > } > if (stmt != null) { > stmt.executeBatch(); > conn.commit(); > mq_session.commit(); > } > } > } finally { > if (stmt != null) > try { > stmt.close(); > stmt = null; > } catch (SQLException e) {} > if (conn != null) > try { > conn.close(); > conn = null; > } catch (SQLException e) {} > } > } catch (Exception e) { > e.printStackTrace(); > try { mq_session.rollback(); } catch (JMSException e1) { > e1.printStackTrace(); } > } > // Sleep here... > } > > And this is how I init MQ session: > > mq_session = mq_connection.createSession(true, Session.AUTO_ACKNOWLEDGE); > > > > > -- http://blog.garytully.com Open Source Integration http://fusesource.com