Announcement Announcement Module
Collapse
No announcement yet.
SimpleContainer include multiple listener but only one consumer is vaild Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleContainer include multiple listener but only one consumer is vaild

    hi,all. I configure multiple listener in a SimpleContainer ,but I found one is valild
    here is configure file
    Code:
    <rabbit:connection-factory id="connectionFactory"
    		host="127.0.0.1" channel-cache-size="25" />
    	<rabbit:queue name="DEMO.TEST" durable="true" />
    	<rabbit:queue name="DEMO.TEST1" durable="true" />
    	<rabbit:direct-exchange name="ex_direct"
    		durable="true">
    		<rabbit:bindings>
    			<rabbit:binding queue="DEMO.TEST" key="aaa" ></rabbit:binding>
    			<rabbit:binding queue="DEMO.TEST1" key="bbb"></rabbit:binding>
    		</rabbit:bindings>
    	</rabbit:direct-exchange>
    	<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"
    		exchange="ex_direct" />
    	<rabbit:admin connection-factory="connectionFactory" />
    	<bean id="msghandler" class="com.sinosoft.handler.MsgHandler"></bean>
    	<bean id="msghandler1" class="com.sinosoft.handler.MsgHandler1"></bean>
    	<rabbit:listener-container id="simplelsnr" 
    		 connection-factory="connectionFactory">
    		 <rabbit:listener id="lsnr0" queues="DEMO.TEST" ref="msghandler"
    			method="handleMessage" />
        	<rabbit:listener id="lsnr1"  queues="DEMO.TEST1" ref="msghandler1"
    			method="handleMessage" /> 
    	</rabbit:listener-container>
    now only msghandler1 is vaild ,I only receive message of "DEMO.TEST1" queue
    Last edited by zone; May 13th, 2013, 04:04 AM.

  • #2
    Turn on DEBUG logging and you will see 2 messages like this every second; which shows that both consumers are working...

    08:46:23.281 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Retrieving delivery for Consumer: tag=[amq.ctag--PjSC63IAkxL3BpsRS6xgw], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
    08:46:23.314 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Retrieving delivery for Consumer: tag=[amq.ctag-dV5Z9MzvJSh4O49WdWHKPQ], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,2), acknowledgeMode=AUTO local queue size=0

    Comment


    • #3
      but there only one
      Code:
      DEBUG - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.nextMessage(185) | Retrieving delivery for Consumer: tag=[amq.ctag-qqoENP0GB7xwh13wmXcDGg], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
      DEBUG - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.nextMessage(185) | Retrieving delivery for Consumer: tag=[amq.ctag-qqoENP0GB7xwh13wmXcDGg], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
      here is starting debug:
      Code:
      DEBUG - org.springframework.amqp.rabbit.connection.CachingConnectionFactory.getDefaultHostName(172) | Using hostname [michelya] for hostname.
      DEBUG - org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.start(361) | Starting Rabbit listener container.
      DEBUG - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(197) | Starting consumer Consumer: tag=[null], channel=null, acknowledgeMode=AUTO local queue size=0
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(273) | Initializing declarations
      DEBUG - org.springframework.amqp.rabbit.connection.CachingConnectionFactory.getCachedChannelProxy(188) | Creating cached Rabbit Channel from AMQChannel(amqp://[email protected]:5672/,1)
      DEBUG - org.springframework.amqp.rabbit.core.RabbitTemplate.execute(598) | Executing callback on RabbitMQ Channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1)
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchanges(326) | declaring Exchange 'ex_direct'
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.declareQueues(340) | declaring Queue 'DEMO.TEST'
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.declareQueues(340) | declaring Queue 'DEMO.TEST1'
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.declareBindings(353) | Binding destination [DEMO.TEST1 (QUEUE)] to exchange [ex_direct] with routing key [aaa]
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.declareBindings(353) | Binding destination [DEMO.TEST (QUEUE)] to exchange [ex_direct] with routing key [bbb]
      DEBUG - org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(317) | Declarations finished
      DEBUG - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(238) | Started on queue 'DEMO.TEST1': Consumer: tag=[amq.ctag-qqoENP0GB7xwh13wmXcDGg], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
      it show is only binded 'DEMO.TEST1' queue and you show have build two channels
      How to configure?
      thanks
      Last edited by zone; May 13th, 2013, 08:49 PM.

      Comment


      • #4
        It's hard for me to debug your environment without benig there live. All I can say is it works just fine for me...

        00:50:48.653 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.core.RabbitAdmin] Declarations finished
        00:50:48.659 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Started on queue 'si.test.queue': Consumer: tag=[null], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
        00:50:48.659 DEBUG [main][org.springframework.context.support.DefaultLifecyc leProcessor] Successfully started bean 'org.springframework.amqp.rabbit.listener.SimpleMe ssageListenerContainer#0'
        00:50:48.659 DEBUG [main][org.springframework.context.support.DefaultLifecyc leProcessor] Starting bean 'org.springframework.amqp.rabbit.listener.SimpleMe ssageListenerContainer#1' of type [class org.springframework.amqp.rabbit.listener.SimpleMes sageListenerContainer]
        00:50:48.659 DEBUG [main][org.springframework.amqp.rabbit.listener.SimpleMes sageListenerContainer] Starting Rabbit listener container.
        00:50:48.659 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Retrieving delivery for Consumer: tag=[amq.ctag-gerH-5gikSyu4Tw4cTQYfQ], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0
        00:50:48.659 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Starting consumer Consumer: tag=[null], channel=null, acknowledgeMode=AUTO local queue size=0
        00:50:48.660 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.connection.Caching ConnectionFactory] Creating cached Rabbit Channel from AMQChannel(amqp://[email protected]:5672/,2)
        00:50:48.662 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Started on queue 'si.test.queue2': Consumer: tag=[null], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,2), acknowledgeMode=AUTO local queue size=0
        00:50:48.662 DEBUG [main][org.springframework.context.support.DefaultLifecyc leProcessor] Successfully started bean 'org.springframework.amqp.rabbit.listener.SimpleMe ssageListenerContainer#1'
        00:50:48.662 DEBUG [SimpleAsyncTaskExecutor-1][org.springframework.amqp.rabbit.listener.BlockingQ ueueConsumer] Retrieving delivery for Consumer: tag=[amq.ctag-xJwOvYpUzJD0kkUc5CgGag], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,2), acknowledgeMode=AUTO local queue size=0
        Here is my configuration...

        Code:
        	<rabbit:connection-factory id="connectionFactory" />
        
        	<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
        
        	<rabbit:admin connection-factory="connectionFactory" />
        
        	<rabbit:queue name="si.test.queue" />
        	<rabbit:queue name="si.test.queue2" />
        
        	<rabbit:direct-exchange name="si.test.exchange">
        		<rabbit:bindings>
        			<rabbit:binding queue="si.test.queue" key="si.test.binding" />
        			<rabbit:binding queue="si.test.queue2" key="si.test.binding2" />
        		</rabbit:bindings>
        	</rabbit:direct-exchange>
        
        	<rabbit:listener-container connection-factory="connectionFactory">
        		<rabbit:listener ref="foo" queue-names="si.test.queue"/>	
        		<rabbit:listener ref="foo" queue-names="si.test.queue2"/>
        	</rabbit:listener-container>
        	
        	<bean id="foo" class="org.springframework.integration.samples.amqp.Foo" />
        I am using 1.1.4,

        Comment


        • #5
          thanks your help
          according your configuaration ,it is work
          i found error

          <rabbit:listener-container id="simplelsnr"
          connection-factory="connectionFactory">
          <rabbit:listener id="lsnr0" queues="DEMO.TEST" ref="msghandler"
          method="handleMessage" />
          <rabbit:listener id="lsnr1" queues="DEMO.TEST1" ref="msghandler1"
          method="handleMessage" />
          </rabbit:listener-container>

          Comment


          • #6
            thanks your help
            according your configuaration ,it is work
            i found error
            Code:
            <rabbit:listener-container id="simplelsnr" 
            connection-factory="connectionFactory">
            <rabbit:listener id="lsnr0" queues="DEMO.TEST" ref="msghandler"
            method="handleMessage" />
            <rabbit:listener id="lsnr1" queues="DEMO.TEST1" ref="msghandler1"
            method="handleMessage" /> 
            </rabbit:listener-container>

            Comment

            Working...
            X