Results 1 to 7 of 7

Thread: Problem with concurrent topic listeners

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    8

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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?

  3. #3
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,036

    Default

    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?
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    My bad, i think i miss-read it

  5. #5
    Join Date
    Feb 2012
    Posts
    8

    Default

    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
    ================

  6. #6
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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)?

  7. #7
    Join Date
    Feb 2012
    Posts
    8

    Default

    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"?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •