问题 Is there any way to get count number of pending messages in jms queue. My aim is to close the connection if there is no message remaining in the queue to process. how can i achieve this. ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url); Connection connection = connectionFactory.createConnection("admin", "admin"); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue(subject);