56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
package com.zhangmeng.mq.config;
|
|
|
|
import org.springframework.amqp.core.*;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Configuration
|
|
public class MqConfig {
|
|
|
|
private static final String Mail_Queue = "mail.queue";
|
|
|
|
private static final String Mail_Exchange = "mail.exchange";
|
|
|
|
private static final String Mail_RoutingKey = "mail.routingKey";
|
|
|
|
private static final String MyStyle_Cloud_Queue = "mystyle.cloud.queue";
|
|
|
|
private static final String MyStyle_Cloud_Exchange = "mystyle.cloud.exchange";
|
|
|
|
private static final String MyStyle_Cloud_RoutingKey = "mystyle.cloud.routingKey";
|
|
|
|
@Bean
|
|
public Queue topicMailQueue() {
|
|
return new Queue(Mail_Queue);
|
|
}
|
|
|
|
@Bean
|
|
public Queue topicMystyleQueue() {
|
|
return new Queue(MyStyle_Cloud_Queue);
|
|
}
|
|
|
|
@Bean
|
|
public Exchange topicExchangeMail() {
|
|
return new TopicExchange(Mail_Exchange);
|
|
}
|
|
|
|
@Bean
|
|
public Exchange topicExchangeMystyle() {
|
|
return new TopicExchange(MyStyle_Cloud_Exchange);
|
|
}
|
|
|
|
@Bean
|
|
public Binding topicBindingExchangeMail() {
|
|
return BindingBuilder.bind(topicMailQueue()).to(topicExchangeMail()).with(Mail_RoutingKey).noargs();
|
|
}
|
|
|
|
@Bean
|
|
public Binding topicBindingExchangeMystyle() {
|
|
return BindingBuilder.bind(topicMystyleQueue()).to(topicExchangeMystyle()).with(MyStyle_Cloud_RoutingKey).noargs();
|
|
}
|
|
}
|