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.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

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

    @Bean
    public Queue fanoutAQueue() {
        return new Queue(Constant.FANOUT_A);
    }

    @Bean
    public Queue fanoutBQueue() {
        return new Queue(Constant.FANOUT_B);
    }

    @Bean
    public Queue fanoutCQueue() {
        return new Queue(Constant.FANOUT_C);
    }


    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanoutExchange");
    }

    @Bean
    public Binding bindingFanoutAExchange(){
        return BindingBuilder.bind(fanoutAQueue()).to(fanoutExchange());
    }
    @Bean
    public Binding bindingFanoutBExchange(){
        return BindingBuilder.bind(fanoutAQueue()).to(fanoutExchange());
    }
    @Bean
    public Binding bindingFanoutCExchange(){
        return BindingBuilder.bind(fanoutAQueue()).to(fanoutExchange());
    }
}
