Announcement Announcement Module
No announcement yet.
Unwanted Multiple DefaultMessageListenerContainers Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unwanted Multiple DefaultMessageListenerContainers

    I'm using spring-jms version 3.0.5 and activeMQ version 4.5.2. When deployed to Tomcat, everything seems to work properly. When deployed to WebSphere, it appears that four separate failover transports are being insantiated, and my MessageListener implementation receives the same message four times for every message that gets published to my topic.

    Here's my config:

    <bean id="activeMQConnectionFactory"
    class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="failover://(tcp://,tcp://>

    <bean id="topic" class="org.apache.activemq.command.ActiveMQTopic">
    <constructor-arg value="TOPIC.ONE" />

    <bean id="jmsTemplate" class="org.sprinframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory" />
    <property name="defaultDestination" ref="topic" />

    <bean name="topicListener" class="" />

    <jms:listener-container connection-factory="connectionFactory" cache="auto" destination-type="topic">
    <jms:listener destination="topic" ref="topicListener" />

    Here's my message listener:

    import javax.jms.MessageListener;
    import org.springframework.stereotype.Component;

    public class TopicListener implements MessageListener {

    public void onMessage(Message msg) {


    And here's what I see in my logs (only on WebSphere)

    11:59:59,764 () INFO (Thread-50) (DefaultLifecycleProcessor) Starting beans in phase 214783647
    12:00:00,140 () INFO (ActiveMQ Task) (FailoverTransport) Successfully connected to tcp://
    12:00:00,253 () INFO (ActiveMQ Task) (FailoverTransport) Successfully connected to tcp://
    12:00:00,342 () INFO (ActiveMQ Task) (FailoverTransport) Successfully connected to tcp://
    12:00:00,423 () INFO (ActiveMQ Task) (FailoverTransport) Successfully connected to tcp://
    12:00:00,492 () INFO (Thread-50) (ContextLoader) Root WebApplicationContext: initialization completed in 100239 ms

    And then once I publish to the topic, I see:

    12:01:00,250 () INFO (org.springframework.jms.listener.DefaultMessageLi stenerContainer#0-1) (TopicListener) logging message
    12:01:00,251 () INFO (org.springframework.jms.listener.DefaultMessageLi stenerContainer#3-1) (TopicListener) logging message
    12:01:00,251 () INFO (org.springframework.jms.listener.DefaultMessageLi stenerContainer#2-1) (TopicListener) logging message
    12:01:00,275 () INFO (org.springframework.jms.listener.DefaultMessageLi stenerContainer#1-1) (TopicListener) logging message

    I've seen some indication that this sort of behavior might be expected if I'd set `concurrentConsumers > 1`, but as far as I can tell, I haven't. How can I make sure I'm only receiving these messages once?


    With debug logging on, I also see:

    2012-10-28 12:00:00,000 () DEBUG (Thread-50) (DefaultLifecycleProcessor) Starting bean 'org.springframework.jms.listener.DefaultMessageLi stenerContainer#0' of type [class org.springframework.jms.listener.DefaultMessageLis tenerContainer]
    2012-10-28 12:00:00,011 () DEBUG (Thread-50) (DefaultLifecycleProcessor) Starting bean 'org.springframework.jms.listener.DefaultMessageLi stenerContainer#1' of type [class org.springframework.jms.listener.DefaultMessageLis tenerContainer]
    2012-10-28 12:00:00,021 () DEBUG (Thread-50) (DefaultLifecycleProcessor) Starting bean 'org.springframework.jms.listener.DefaultMessageLi stenerContainer#2' of type [class org.springframework.jms.listener.DefaultMessageLis tenerContainer]
    2012-10-28 12:00:00,029 () DEBUG (Thread-50) (DefaultLifecycleProcessor) Starting bean 'org.springframework.jms.listener.DefaultMessageLi stenerContainer#3' of type [class org.springframework.jms.listener.DefaultMessageLis tenerContainer]

    Why would Spring create four of these beans?

  • #2
    Sorry for not getting to this sooner. We are in the process of moving to StackOverflow for our forums.

    This question is probably a better candidate for StackOverflow, perhaps against the #spring-jms tag.
    If you do post it there, please reply here with the link.