package com.ssj.framework.core.rabbitmq;

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;


/**
 * Fanout 就是我们熟悉的广播模式或者订阅模式
 * 可用于同时通过各模块
 * @author wuwen
 * 2019年4月17日15:30:10 
 */
@Configuration
public class FanoutRabbitConfig {
	
	//总机
	public final static String exchange_ssj = "exchange_ssj";
	
	//队列
	public final static String fanout_task = "fanout_task";
	public final static String fanout_sys = "fanout_sys";
	public final static String fanout_kmt = "fanout_kmt";
	public final static String fanout_weixin = "fanout_weixin";
	public final static String fanout_weixin_api = "fanout_weixin_api";
	public final static String fanout_web = "fanout_web";
	
	
    @Bean
    FanoutExchange fanoutExchange() {
        return new FanoutExchange(FanoutRabbitConfig.exchange_ssj);
    }

    @Bean
    public Queue TaskMessage() {
        return new Queue(FanoutRabbitConfig.fanout_task);
    }
    @Bean
    public Queue SysMessage() {
        return new Queue(FanoutRabbitConfig.fanout_sys);
    }
    @Bean
    public Queue KmtMessage() {
        return new Queue(FanoutRabbitConfig.fanout_kmt);
    }
    @Bean
    public Queue WeixinMessage() {
        return new Queue(FanoutRabbitConfig.fanout_weixin);
    }
    @Bean
    public Queue WeixinApiMessage() {
        return new Queue(FanoutRabbitConfig.fanout_weixin_api);
    }
    @Bean
    public Queue WebMessage() {
        return new Queue(FanoutRabbitConfig.fanout_web);
    }
    
    
    
    @Bean
    Binding bindingExchangeTask(Queue TaskMessage,FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(TaskMessage).to(fanoutExchange);
    }
    @Bean
    Binding bindingExchangeSys(Queue SysMessage, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(SysMessage).to(fanoutExchange);
    }
    @Bean
    Binding bindingExchangeKmt(Queue KmtMessage, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(KmtMessage).to(fanoutExchange);
    }
    @Bean
    Binding bindingExchangeWeixin(Queue WeixinMessage, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(WeixinMessage).to(fanoutExchange);
    }
    @Bean
    Binding bindingExchangeWeixinApi(Queue WeixinApiMessage, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(WeixinApiMessage).to(fanoutExchange);
    }
    @Bean
    Binding bindingExchangeWeb(Queue WebMessage, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(WebMessage).to(fanoutExchange);
    }

}
