package com.skr.mdm.rabbitmq;

import com.skr.mdm.constant.RabbitmqExchangeConstants;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

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

/**
 * rabbitmq交换机注册
 * @author nfq
 * @date 2022/06/13 16:42
 */
@Configuration
public class RabbitMQExchange {

    /**
     * 延时队列交换机
     * @return
     */
    @Bean
    public CustomExchange delayedExchange() {
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("x-delayed-type", "direct");
        return new CustomExchange(RabbitmqExchangeConstants.DELAYED_EXCHANGE, "x-delayed-message", true, false, arguments);
    }
}
