package cn.freemud.amp;

import cn.freemud.amp.constant.QueueMetadata;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * All rights Reserved, Designed By www.freemud.cn
 *
 * @version V1.0
 * @Title: ${FILE_NAME}
 * @Package com.freemud.mail.core
 * @Description: ${TODO}(用一句话描述该文件做什么)
 * @author: aiqi.gong
 * @date: 2019/3/11 18:26
 * @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
 * 注意：本内容仅限于上海非码科技内部传阅，禁止外泄以及用于其他的商业目
 */
@Configuration
public class OpenPushOrderConfig {

    /**
     * 写入RabbitMQ使用的默认队列
     *
     * @return
     */
    @Bean
    public Queue openPushOrderQueue() {
        return new Queue(QueueMetadata.Order.OPEN_QUEUE_NAME, true);
    }

    /**
     * 绑定消息队列
     *
     * @param pushOrderQueue 消息队列
     * @param topicExchange  RabbitMQ Fanout Exchange
     * @return 消息队列绑定
     */
    @Bean
    Binding bindingPushOrder(@Qualifier("openPushOrderQueue") Queue pushOrderQueue, Exchange topicExchange) {
        return BindingBuilder.bind(pushOrderQueue).to(topicExchange).with(QueueMetadata.Order.OPEN_QUEUE_NAME_ROUTING_KEY).noargs();
    }


}
