package com.bootdo.datasend.dianxin.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public Queue warnQueue() {
        // 创建队列 myQueue
        return new Queue("warnrecord", true);
    }

    @Bean
    public Queue userQueue() {
        return new Queue("userrecord", true);
    }

    @Bean
    public Queue vehicleQueue() {
        return new Queue("vehiclerecord", true);
    }

    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("warnrecord");
    }

    @Bean
    public Binding bindingWarnQueue(Queue warnQueue, TopicExchange exchange) {
        return BindingBuilder.bind(warnQueue).to(exchange).with("routing.key.warnrecord");
    }

    @Bean
    public Binding bindingUserQueue(Queue userQueue, TopicExchange exchange) {
        return BindingBuilder.bind(userQueue).to(exchange).with("routing.key.userrecord");
    }

    @Bean
    public Binding bindingVehicleQueue(Queue vehicleQueue, TopicExchange exchange) {
        return BindingBuilder.bind(vehicleQueue).to(exchange).with("routing.key.vehiclerecord");
    }

}
