package org.jeecg.modules.shop.customer.queue;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.Binding;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class RabbitCustomer {

    public static final String ADDCUSTOMER_EXCHANGE = "customerExchange";

    public static final String ADDCUSTOMER_ROUTE = "customerKey";

    public static final String ADDCUSTOMER_QUEUE = "customerQueue";

    public static final String UPDATECUSTOMER_EXCHANGE = "customerExchange";

    public static final String UPDATECUSTOMER_ROUTE = "customerKey";

    public static final String UPDATECUSTOMER_QUEUE = "customerQueue";

    @Bean
    public DirectExchange exchange(){
        return new DirectExchange(ADDCUSTOMER_EXCHANGE);
    }

    @Bean
    public DirectExchange updateExchange(){
        return new DirectExchange(UPDATECUSTOMER_EXCHANGE);
    }


    @Bean
    public Queue queue(){
        return new Queue(ADDCUSTOMER_QUEUE);
    }

    @Bean
    public Queue updateQueue(){
        return new Queue(UPDATECUSTOMER_QUEUE);
    }

    @Bean
    public Binding binding(DirectExchange exchange, Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with(ADDCUSTOMER_ROUTE);
    }

    @Bean
    public Binding updateBinding(DirectExchange exchange, Queue updateQueue){
        return BindingBuilder.bind(updateQueue).to(exchange).with(UPDATECUSTOMER_ROUTE);
    }
}
