Could I please get some advice on how I should implement functionality to enable a "org.springframework.amqp.rabbit.listener.SimpleMe ssageListenerContainer" to "start" and "stop" picking up messages from a queue.
I have implemented a spring web application which defines the following within an application Context file.
I place 10 messages on the queue and enable the listener by doing the following.Code:<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="messageListenerContainer" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer"> <property name="connectionFactory" ref="connectionFactory" /> <property name="queueName" value="cbs.push.queue" /> <property name="concurrentConsumers" value="1" /> <property name="messageListener" ref="cbsListener" /> <property name="channelTransacted" value="true" /> <property name="autoStartup" value="false" /> </bean> <bean id="cbsListener" class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter"> <property name="delegate" ref="msgController" /> </bean>
I disable the listener in a similar fashion by callingCode:SimpleMessageListenerContainer sml = null; try{ sml = (SimpleMessageListenerContainer) applicationContext.getBean("messageListenerContainer"); sml.start(); }catch(Exception e){ logger.debug("*******AppController.handleRequestInternal() -- Unable to retrieve messageListenerContainer"); }
sml.stop();
The first time I enable/disable the listener everything seems to be working fine. However, when I attempt to enable the listener a second time the messages are not being picked up from the queue. I don't see any exceptions in my log.
Any advice on how i could modify my implementation to have control over the listener would be greatly appreciated.


Reply With Quote
