Hi All,
I am developing an application which uses Spring's DefaultMessageListenerContainer to implement a MDP. As part of this application I have to implement a task which will run on a schedule (every x minutes) which I am implementing via Springs scheduledTasks support:
Before this code executes it needs to stop/pause the JMS Listener container to avoid a potential race condition. As such I have attempted to implement this via the SmartLifecycle stop callback e.g:Code:<task:scheduled-tasks scheduler="heartbeatScheduler"> <task:scheduled ref="heartbeatService" method="processHeartbeat" cron="${heartbeat.cron}"/> </task:scheduled-tasks> <task:scheduler id="heartbeatScheduler" pool-size="1"/>
The issue however is that although the messageListenerContainer.start(); is called and the container reports that it is both active and running, from checking the activemq console the JMS connection is never reinstated.Code:messageListenerContainer.stop(new Runnable() { @Override public void run() { LOGGER.info("JMS Container stopped executing task"); performTask(); LOGGER.info("Task complete starting JMS Container"); messageListenerContainer.start(); } });
If however I stop the container via the stop() callback and poll the container until the activeConsumerCount == 0 and then restart, the JMS Connection is reinstated correctly.
My message listener container config is as follows:
Any help you could provide would be much appreciated.Code:<bean id="adapterListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="jmsConnectionFactory"/> <property name="destinationName" value="${inbound.destination}" /> <property name="messageListener" ref="messageListener" /> <property name="transactionManager" ref="jmsTransactionManager" /> <property name="maxConcurrentConsumers" value="${max.concurrent.consumers}" /> </bean>


Reply With Quote
