rabbitMq多个队列多种任务同时监听

生产者:配置文件


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/rabbit
     http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
    
    
    
    
    
    
    
    
    
    
       
    
    
        
            
            
            
            
        

    

    
    

消息发送方法

// exchange 指定交换机  routingKey 设置任务key用于绑定队列  object 任务消息内容

public void sendMessage(String exchange, String routingKey, Object object) {
        amqpTemplate.convertAndSend(exchange, routingKey, object);
    }

消费者


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/rabbit
     http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
     
   
   



     
   
   
   



    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/rabbit
     http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">
    
        
    
        
    

    

    
    
    
    
    
    
    
    
    
    
     
    
    

    

    
 

 

 


      
    
    
    
    
    
    
    






转载于:https://www.cnblogs.com/qinshuipo/articles/6655279.html

你可能感兴趣的:(rabbitMq多个队列多种任务同时监听)