You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package com.glxp.api.config.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;
|
|
|
|
|
|
@Configuration
|
|
public class TopicRabbitConfig {
|
|
//绑定键
|
|
public final static String common = "topic.common";
|
|
public final static String trace = "topic.trace";
|
|
|
|
@Bean
|
|
public Queue firstQueue() {
|
|
return new Queue(TopicRabbitConfig.trace);
|
|
}
|
|
|
|
@Bean
|
|
public Queue secondQueue() {
|
|
return new Queue(TopicRabbitConfig.common);
|
|
}
|
|
|
|
@Bean
|
|
TopicExchange exchange() {
|
|
return new TopicExchange("topicExchange");
|
|
}
|
|
|
|
|
|
@Bean
|
|
Binding bindingExchangeMessage() {
|
|
return BindingBuilder.bind(firstQueue()).to(exchange()).with(trace);
|
|
}
|
|
|
|
@Bean
|
|
Binding bindingExchangeMessage2() {
|
|
return BindingBuilder.bind(secondQueue()).to(exchange()).with("topic.#");
|
|
}
|
|
|
|
}
|