This commit is contained in:
xiangwb
2018-04-27 15:05:00 +08:00
parent 87364918f6
commit 9dba63145f
5 changed files with 9 additions and 9 deletions
@@ -0,0 +1,45 @@
package com.xwbing.rabbit;
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;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/4/25 14:28
* 作者: xiangwb
* 说明: topic交换机配置
*/
@Configuration
public class TopicExchangeConfig {
//声明队列
@Bean
public Queue serverInvokeQueue() {
return new Queue(RabbitConstant.SERVER_INVOKE_QUEUE, true);//true表示持久化该队列
}
@Bean
public Queue httpRequestQueue() {
return new Queue(RabbitConstant.HTTP_REQUEST_QUEUE, true);
}
//声明交换机
@Bean
public TopicExchange topicExchange() {
return new TopicExchange(RabbitConstant.CONTROL_EXCHANGE);
}
//绑定
@Bean
public Binding bindingExchangeMessage() {
return BindingBuilder.bind(serverInvokeQueue()).to(topicExchange()).with(RabbitConstant.SERVER_INVOKE_ROUTING_KEY);//*表示一个词,#表示零个或多个词
}
@Bean
public Binding bindingExchangeMessages() {
return BindingBuilder.bind(httpRequestQueue()).to(topicExchange()).with(RabbitConstant.HTTP_REQUEST_ROUTING_KEY);
}
}