package com.gz.config.rabbitmq;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * rabbitmq默认交换器
 * @author LiuchangLan
 * @date 2020/11/18 16:20
 */
@Configuration
@Slf4j
public class RabbitMQExchangeConfig {

    @Value("${rabbitmq.data-exchange}")
    private String dataExchangeName;

    @Value("${rabbitmq.dlx-data-exchange}")
    private String dlxDataExchangeName;

    /**
     * @description 数据交换机
     * @author LiuChangLan
     * @since 2020/11/18 16:39
     */
    @Bean
    DirectExchange dataExchange(){
        log.info("[rabbitMQ]创建数据交换机");
        return new DirectExchange(dataExchangeName,true,false);
    }


    /**
     * @description 死信队列交换机
     * @author LiuChangLan
     * @since 2021/3/8 19:22
     */
    @Bean
    DirectExchange dlxDataExchange(){
        log.info("[rabbitMQ]创建死信交换机");
        return new DirectExchange(dlxDataExchangeName,true,false);
    }
}
