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"); } }
个人学习笔记,记录日常学习,便于查阅及加深,仅为方便个人使用。