package com.persagy.bdtp.adm.config;

import com.persagy.bdtp.adm.common.AdmMessageConst;
import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@Configuration
public class AdmRabbitConfig {

    @Bean
    public TopicExchange m2dExchange() {
        return new TopicExchange(AdmMessageConst.ADM_EXCHANGE);
    }

    @Bean
    public Queue m2dQueue(){
        return new Queue(AdmMessageConst.M2D_QUEUE);
    }

    @Bean
    public Binding m2dBinding() {
        return BindingBuilder.bind(m2dQueue()).to(m2dExchange()).with(AdmMessageConst.M2D_ROUTING);
    }

    @Bean
    public TopicExchange admExchange() {
        return new TopicExchange(AdmMessageConst.ADM_EXCHANGE);
    }

    @Bean
    public Queue admD2mQueue(){
        return new Queue(AdmMessageConst.ADM_D2M_QUEUE);
    }

    @Bean
    public Binding admD2mBinding() {
        return BindingBuilder.bind(admD2mQueue()).to(admExchange()).with(AdmMessageConst.ADM_D2M_ROUTING);
    }

}
