package com.zcxk.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Value("${receive.exchange.name}")
    private  String receiveExchangeName;
    @Value("${dispath.routing.key}")
    private  String dispathRoutingKey;
    @Value("${dispath.queue}")
    private  String dispathQueue;


    @Bean
    public Queue dispathQueue() {
        return QueueBuilder.nonDurable(dispathQueue).build();
    }

    @Bean
    public Exchange exchange() {

        return new TopicExchange(receiveExchangeName, false, false, null);
    }
    @Bean
    public Binding dispathBinding() {
        return new Binding(dispathQueue,
                Binding.DestinationType.QUEUE,
                receiveExchangeName,
                dispathRoutingKey,
                null);
    }

}
