I have defined a messageListenerContainer (session scoped) within my webapplication and disabled the startup ofthe listener on deployment of the webapp in tomcat.
Code:
<bean id="messageListenerContainer" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer" scope="session">
<property name="connectionFactory" ref="connectionFactory" />
<property name="queueName" value="anu.cbs.push.queue"/>
<property name="concurrentConsumers" value="1" />
<property name="messageListener" ref="messageListenerAdapter" />
<property name="autoStartup" value="false" />
</bean>
<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.SingleConnectionFactory">
<constructor-arg value="localhost"/>
<property name="username" value="guest"/>
<property name="password" value="guest"/>
</bean>
<bean id="messageListenerAdapter" class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter" >
<property name="delegate" ref="msgHandler" />
</bean>
<bean id="msgHandler" class="com.catmktg.digitalgateway.consumer.asynch.MessageHandler">
</bean>
IMy web application code provides links to disable and enable the listener. From what I'm observing the enabling logic works but disabling the listener seems to be incorrect.
Code To enable the listener
Code:
pplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
SimpleMessageListenerContainer sml = (SimpleMessageListenerContainer) applicationContext.getBean("messageListenerContainer");
sml.start();
Code To disable the listener
Upon disabling the listener I am not able to place messages on the queue. It seems the listener is still enabled.
Am i using the correct logic to enable/disable listeners?