rabbitmq config文件

 

package com.zhetang.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * User:wq
 * Date:2021/4/22
 * Time: 10:04
 * Description: No Description
 */
@Configuration
public class QueueConfig {
    @Value("${mq.config.exchange}")
    private String exchange;
    @Value("${mq.config.queue.name}")
    private String queue;
    @Value("${mq.config.queue.routing.key}")
    private String routeKey;
    @Bean
    public Queue createQueue(){
        return new Queue(exchange);
    }
    @Bean
    public DirectExchange createExchange(){
        return new DirectExchange(exchange,true,false);
    }
    //绑定  将队列和交换机绑定, 并设置用于匹配键
    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(createQueue()).to(createExchange()).with(routeKey);
    }

    @Bean
    DirectExchange lonelyDirectExchange() {
        return new DirectExchange("lonelyDirectExchange");
    }



}

 

posted @ 2021-04-22 11:04  wq9  阅读(380)  评论(0)    收藏  举报