Announcement Announcement Module
Collapse
No announcement yet.
Problem with concurrent topic listeners Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with concurrent topic listeners

    Hi

    I have 2 listeners configured using Spring with each listener listening to the same topic message. I expect only one listener instance/thread for each of the listeners as the concurrency is set to 1 as follows. When the topic message is received as expected I see only one listener instance for Listener1 however listener2 has 2 instances processing the same message concurrently. Any ideas how I can enforce only one listener instance for listener2?

    My listener configuration:
    ===================
    <jms:listener-container client-id="ListenerOne" container-type="default" error-handler="jmsErrorHandler" destination-type="topic" connection-factory="jndiJmsConnFactory" acknowledge="auto" concurrency="1">
    <jms:listener destination="${destination.topic1}" ref="listenerOne" method="onMessage" />
    </jms:listener-container>

    <jms:listener-container client-id="ListenerTwo" container-type="default" error-handler="jmsErrorHandler" destination-type="topic" connection-factory="jndiJmsConnFactory" acknowledge="auto" concurrency="1">
    <jms:listener destination="${destination.topic1}" ref="listenerTwo" method="onMessage" />
    </jms:listener-container>

    Thanks
    Chandru

  • #2
    Well
    If I understand correctly you are trying to implement Point-to-Point messaging paradigm where a Message is only processed once. Is this correct?
    If so, why do you use Topic instead of Queue? Topic is the implementation of Pub-Sub messaging paradigm which means every listener subscribing to the topic would get a Message. Am I missing something?

    Comment


    • #3
      Please use [ code ] ... [ /code ] tags when posting code or config (no spaces inside brackets).

      Can you provide a TRACE level log that shows the containers starting up, and processing at least one message?

      What version of Spring are you using?

      Comment


      • #4
        My bad, i think i miss-read it

        Comment


        • #5
          Hi Gary

          Thanks for your response.


          My Spring JMs listener configuration
          ===========================

          Code:
          <jms:listener-container client-id="ListenerMediaRegistered" container-type="default" error-handler="jmsErrorHandler" destination-type="topic" 
          		connection-factory="jndiJmsConnFactory" acknowledge="auto" concurrency="1">
          		<jms:listener destination="${media.registered.destination}" ref="listenerMediaRegisted"
          			method="onMessage" />
          	</jms:listener-container> 
            
          <jms:listener-container client-id="ListenerPhotopassClaim"  container-type="default" error-handler="jmsErrorHandler" destination-type="topic" 
          		connection-factory="jndiJmsConnFactory" acknowledge="auto" concurrency="1">
          	    <jms:listener destination="${media.registered.destination}" ref="listenerPhotopassClaim"
          			method="onMessage" />
          </jms:listener-container>

          Log fole showing listener processing
          ===========================
          [2012-11-06 11:52:58,288] [DEBUG] [com.wdpr.nge.media.msl.util.ListenerMediaRegistere d] -[Listener thread org.springframework.jms.listener.DefaultMessageLis tenerContainer#8-1 MessageId = ID:ffffffffcbed081a:15120004:13AD6DA8D83, Got Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          [2012-11-06 11:52:58,289] [DEBUG] [com.wdpr.nge.media.msl.util.ListenerPhotopassClaim] -[Listener thread org.springframework.jms.listener.DefaultMessageLis tenerContainer#9-1 MessageId = ID:ffffffffcbed081a:15120004:13AD6DA8D83, Got Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          [2012-11-06 11:52:58,289] [DEBUG] [com.wdpr.nge.media.msl.util.ListenerPhotopassClaim] -[Listener thread org.springframework.jms.listener.DefaultMessageLis tenerContainer#14-1 MessageId = ID:ffffffffcbed081a:15120004:13AD6DA8D83, Got Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

          Spring Version: 3.0.5
          ================

          Comment


          • #6
            It appears as though you have 2 instances of the *container* rather than 2 consumers on that container, based on both of these bean ids in the log: DefaultMessageListenerContainer#9-1 and DefaultMessageListenerContainer#14-1 (for the same listener bean)

            Are you sure there is not some additional configuration beyond what you are showing here? (another listener-container in an XML file being imported, or something similar)?

            Comment


            • #7
              There is no other container configuration for the specific listener. Although I see 2 container instances with Sonic this is not the case with ActiveMQ. With AcitiveMQ as the log shows below, only one instance of the bean processes the message whereas with Sonic I see 2 bean instances processing the same message?

              What is the pros and cons of configuring 1 container per listener vs one container for all listeners? Currently I have each listener configured in its own container.

              [2012-11-06 14:27:00,037] [DEBUG] [com.wdpr.nge.media.msl.util.ListenerMediaRegistere d] -[Listener thread org.springframework.jms.listener.DefaultMessageLis tenerContainer#8-2 MessageId = ID:XXXXXXXX-55981-1352233598682-2:1:1:1:1, Got Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              [2012-11-06 14:27:00,040] [DEBUG] [com.wdpr.nge.media.msl.util.ListenerPhotopassClaim] -[Listener thread org.springframework.jms.listener.DefaultMessageLis tenerContainer#9-2 MessageId = ID:XXXXXXXX-55981-1352233598682-2:1:1:1:1, Got Message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

              Comment

              Working...
              X