package com.lovecoding.rabbitmq.consumer;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }
    //接收北京天气
    @Bean
    public Queue topicQueue(){
        return new Queue("topicQueue");
    }
    //接收哈尔滨天气
    @Bean
    public Queue topicQueueT8(){
        return new Queue("topicQueueT8");
    }
    //全国天气
    @Bean
    public Queue topicQueueT9(){
        return new Queue("topicQueueT9");
    }

    @Bean
    public Binding topicExchangeBindingT8(Queue topicQueueT8, TopicExchange topicExchange ){
        return BindingBuilder.bind(topicQueueT8).to(topicExchange).with("com.lc.haerbin");
    }

    @Bean
    public  Binding topicExchangeBinding(Queue topicQueue, TopicExchange topicExchange) {
        return BindingBuilder.bind(topicQueue).to(topicExchange).with("com.lc.beijing");
    }

    @Bean
    public Binding topicExchangeBindingT9(Queue topicQueueT9, TopicExchange topicExchange){
        //return BindingBuilder.bind(topicQueueT9).to(topicExchange).with("com.#");
        return BindingBuilder.bind(topicQueueT9).to(topicExchange).with("com.lc.*");
    }

}
