package cn.ysk.cashier.config;

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

@Configuration
public class RabbitConfig {
    public static final String QUEUE_STOCK_RECORD_SALE = "queue.stock.record.sale";
    public static final String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
    public static final String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";

    public static final String QUEUE_STOCK_RECORD = "queue.stock.record";
    public static final String ROUTING_STOCK_RECORD= "routing.stock.record";


    @Bean
    Queue stockRecordSaleQueue() {
        return new Queue(QUEUE_STOCK_RECORD_SALE);
    }

    @Bean
    DirectExchange stockRecordExchange() {
        return new DirectExchange(EXCHANGE_STOCK_RECORD);
    }

    @Bean
    Binding binding(Queue stockRecordSaleQueue, DirectExchange stockRecordExchange) {
        return BindingBuilder.bind(stockRecordSaleQueue).to(stockRecordExchange).with(ROUTING_STOCK_RECORD_SALE);
    }

    @Bean
    Queue stockRecordSaleQueue2() {
        return new Queue(QUEUE_STOCK_RECORD);
    }

    @Bean
    Binding binding2(Queue stockRecordSaleQueue2, DirectExchange stockRecordExchange) {
        return BindingBuilder.bind(stockRecordSaleQueue2).to(stockRecordExchange).with(ROUTING_STOCK_RECORD);
    }
}
