package com.pannk.config;

import com.pannk.cons.Constant;
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;

/**
 * Created by wolf on 20-11-17.
 */
@Configuration
public class TopicRabbitMQConfig {


    @Bean
    public Queue orderQueue() {
        return new Queue(Constant.TOPIC_ORDER);
    }

    @Bean
    public Queue consultQueue() {
        return new Queue(Constant.TOPIC_CONSULT);
    }


    @Bean
    TopicExchange topicExchange() {
        return new TopicExchange("topicExchange");
    }

    @Bean
    public Binding bindingExchangeOrder() {
        return BindingBuilder.bind(orderQueue()).to(topicExchange()).with(Constant.TOPIC_ORDER);
    }

    @Bean
    public Binding bindingExchangeConsult() {
        return BindingBuilder.bind(consultQueue()).to(topicExchange()).with(Constant.TOPIC_ALL);
    }


}
