Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to start/stop ActiveMQ listener programatically?

Avatar of SarahDeng
SarahDeng asked on
JavaWeb DevelopmentJava EE
7 Comments1 Solution5954 ViewsLast Modified:
Hi Experts,
I have ActiveMQ 5.4 and Spring3.1. This MessageListener will be kicked off once there is a message dropped in the queue. Because this MessageListener will insert a large amount of data, I wonder if there is a way to stop this Listener, and restart it once the a large amount of data inserted into DB.
How to stop/restart the listener programatically? Thanks!

public class ExampleListener implements MessageListener {
      public void onMessage(Message message) {
                        insert a LARGE amount of data into DB table using Hibernate.

This is Spring ApplicationContext.xml

<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
 <bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
 <property name="connectionFactory">
  <bean class="org.apache.activemq.ActiveMQConnectionFactory">
 <property name="brokerURL">
      <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
          <property name="connectionFactory" ref="jmsFactory"/>
      <!-- this is the Message Driven POJO (MDP) -->
      <bean id="messageListener" class="com.sprint.cto.sp.helloworld.ExampleListener" />
      <!-- and this is the message listener container -->
      <bean id="jmsContainer"
            <property name="connectionFactory" ref="jmsFactory"/>
            <property name="destination" ref="destination"/>
            <property name="messageListener" ref="messageListener" />
Avatar of ajaycv

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers