geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tamer Nassar <tamernas...@yahoo.com>
Subject Queue listener doesn't stop
Date Tue, 07 Apr 2009 14:43:37 GMT
Hi,
I created a listener for a queue. To start this listener I added it to the init() method in
a servlet and I load the servlet at the start of my war file. So in my web.xml, I start the
servlet (which starts my listener) on load. It works perfect. 

  <servlet>
    <display-name>TestListener</display-name>
    <servlet-name>TestListener</servlet-name>
    <servlet-class>org.model.listener.TestListener</servlet-class>
    <load-on-startup>1</load-on-startup>    
  </servlet>
  <servlet-mapping> ...  </servlet-mapping>

The problem is when I stop my deployed war file. the listener doesn't stop, even if redeploy
new version of my war, it keeps adding new consumers to the queue. 
The only way to stop this listner is to restart my WASCE.

Is there anyway to stop the load-on-startup servlet (the listner) when I stop my war file???
Please advice.


I use ActiveMQ5.2, Geronimo and WACE2.1

Servlet/Listner code:
public class TestListener extends HttpServlet implements MessageListener {
.....
    public void init(ServletConfig config) throws ServletException {
 
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(failover:tcp://localhost:51616?wireFormat.maxInactivityDuration=-1&keepAlive=true&connectionTimeout=0);
        Connection connection;
        try {
            ((ActiveMQConnectionFactory) connectionFactory).setDispatchAsync(false);
            connection = connectionFactory.createConnection();

            connection.start();
            this.session = connection.createSession(this.transacted, ackMode);
            Destination ListenerRequestQueue = this.session.createQueue("testQ");
 
            MessageConsumer consumer = this.session.createConsumer(ListenerRequestQueue);
            consumer.setMessageListener(this);
        } catch (JMSException e) {
            // Handle the exception appropriately
        }
    }
....
}
Mime
View raw message