package com.trade.service.contract.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 RabbitMqConfig {

    public static final String QUEUE_E_SIGN_CALLBACK = "eSignCallback";
    public static final String E_SIGN_EXCHANGE = "eSignExchange";
    public static final String QUEUE_E_SIGN_CALLBACK_ROUTING_KEY = "eSignCallback.routingKey";

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

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

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