//package me.zhengjie.config.rabbitmq.order;
//
//import lombok.Data;
//import me.zhengjie.config.rabbitmq.RabbitmqConfig;
//import org.springframework.amqp.core.*;
//import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitAdmin;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
//@Data
//@Configuration
//public class OrderConsumer {
//    @Autowired
//    private RabbitmqConfig rabbitmqConfig;
//    public static final String NAME_ORDER = "dish_trade_produce";
//    public final static String MODULE_NAME_ORDER = "dishTp";
//
//    public final static String CONNECTION_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.CONNECTION;
//    public final static String TEMPLATE_ORDER_CON = MODULE_NAME_ORDER+ RabbitmqConfig.TEMPLATE;
//    public final static String LISTENER_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.LISTENER;
//    public final static String ADMIN_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.ADMIN;
//    public final static String EXCHANGE_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.EXCHANGE;
//    public final static String QUEUE_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.QUEUE;
//    public final static String BINDING_ORDER_CON = MODULE_NAME_ORDER+RabbitmqConfig.BINDING;
//
//    @Bean(name = CONNECTION_ORDER_CON)
//    @Primary
//    public ConnectionFactory connectionFactory(){
//        return rabbitmqConfig.connectionFactory(NAME_ORDER);
//    }
//
//    @Bean(name = TEMPLATE_ORDER_CON)
//    @Primary
//    public RabbitTemplate rabbitTemplate(@Qualifier(CONNECTION_ORDER_CON) ConnectionFactory connectionFactory ) {
//        return rabbitmqConfig.rabbitTemplate(connectionFactory);
//    }
//
//    @Bean(name = LISTENER_ORDER_CON)
//    @Primary
//    public SimpleRabbitListenerContainerFactory listenerFactory(
//            SimpleRabbitListenerContainerFactoryConfigurer configurer,
//            @Qualifier(CONNECTION_ORDER_CON) ConnectionFactory connectionFactory) {
//        return rabbitmqConfig.listenerFactory(configurer,connectionFactory);
//    }
//
//    @Bean(name = ADMIN_ORDER_CON)
//    @Primary
//    AmqpAdmin amqpAdmin(@Qualifier(CONNECTION_ORDER_CON) ConnectionFactory connectionFactory) {
//        return new RabbitAdmin(connectionFactory);
//    }
//
//    @Bean(EXCHANGE_ORDER_CON)
//    @Primary
//    public DirectExchange exchange(@Qualifier(ADMIN_ORDER_CON) AmqpAdmin amqpAdmin) {
//        return rabbitmqConfig.exchange(NAME_ORDER,amqpAdmin);
//    }
//
//    @Bean(QUEUE_ORDER_CON)
//    @Primary
//    Queue queue(@Qualifier(ADMIN_ORDER_CON)AmqpAdmin amqpAdmin) {
//        return rabbitmqConfig.queue(NAME_ORDER,amqpAdmin);
//    }
//
//    @Bean(BINDING_ORDER_CON)
//    @Primary
//    Binding bindingPersonDirect(@Qualifier(ADMIN_ORDER_CON)AmqpAdmin amqpAdmin) {
//        Binding binding = BindingBuilder.bind(queue(amqpAdmin)).to(exchange(amqpAdmin)).with(NAME_ORDER);
//        binding.setAdminsThatShouldDeclare(amqpAdmin);
//        return binding;
//    }
//}
