|
@@ -35,18 +35,17 @@ public class RabbitConfig {
|
|
|
private String password;
|
|
|
|
|
|
|
|
|
- public static final String EXCHANGE_A = "my-mq-exchange_A";
|
|
|
- public static final String EXCHANGE_B = "my-mq-exchange_B";
|
|
|
- public static final String EXCHANGE_C = "my-mq-exchange_C";
|
|
|
|
|
|
+ public static final String EXCHANGE_SETTLE = "settexchange";
|
|
|
|
|
|
- public static final String QUEUE_A = "QUEUE_A";
|
|
|
- public static final String QUEUE_B = "QUEUE_B";
|
|
|
- public static final String QUEUE_C = "QUEUE_C";
|
|
|
|
|
|
- public static final String ROUTINGKEY_A = "spring-boot-routingKey_A";
|
|
|
- public static final String ROUTINGKEY_B = "spring-boot-routingKey_B";
|
|
|
- public static final String ROUTINGKEY_C = "spring-boot-routingKey_C";
|
|
|
+
|
|
|
+ public static final String QUEUE_SETTLE = "confirmSettle";
|
|
|
+ public static final String QUEUE_PRESETTLE = "preSettle";
|
|
|
+
|
|
|
+
|
|
|
+ public static final String ROUTINGKEY_CONFIRM = "confirmSettle";
|
|
|
+ public static final String ROUTINGKEY_PRE = "preSettle";
|
|
|
|
|
|
@Bean
|
|
|
public ConnectionFactory connectionFactory() {
|
|
@@ -75,59 +74,38 @@ public class RabbitConfig {
|
|
|
DirectExchange:按照routingkey分发到指定队列
|
|
|
TopicExchange:多关键字匹配
|
|
|
*/
|
|
|
- @Bean
|
|
|
- public DirectExchange directExchange() {
|
|
|
- return new DirectExchange(EXCHANGE_A);
|
|
|
- }
|
|
|
|
|
|
@Bean
|
|
|
- public FanoutExchange fanoutExchange() {
|
|
|
- return new FanoutExchange(EXCHANGE_B);
|
|
|
+ public DirectExchange directExchange() {
|
|
|
+ return new DirectExchange(EXCHANGE_SETTLE);
|
|
|
}
|
|
|
|
|
|
- @Bean
|
|
|
- public TopicExchange topicExchange() {
|
|
|
- return new TopicExchange(EXCHANGE_C);
|
|
|
- }
|
|
|
/**
|
|
|
- * 获取队列A
|
|
|
+ * 获取队列Pre
|
|
|
* @return
|
|
|
*/
|
|
|
@Bean
|
|
|
- public Queue queueA() {
|
|
|
+ public Queue queuePre() {
|
|
|
//队列持久
|
|
|
- return new Queue(QUEUE_A, true);
|
|
|
+ return new Queue(QUEUE_PRESETTLE, true);
|
|
|
}
|
|
|
@Bean
|
|
|
- public Binding binding() {
|
|
|
+ public Binding bindingPre() {
|
|
|
|
|
|
- return BindingBuilder.bind(queueA()).to(directExchange()).with(RabbitConfig.ROUTINGKEY_A);
|
|
|
+ return BindingBuilder.bind(queuePre()).to(directExchange()).with(RabbitConfig.ROUTINGKEY_PRE);
|
|
|
}
|
|
|
/**
|
|
|
- * 获取队列B
|
|
|
+ * 获取队列confirm
|
|
|
* @return
|
|
|
*/
|
|
|
@Bean
|
|
|
- public Queue queueB() {
|
|
|
+ public Queue queueConfirm() {
|
|
|
//队列持久
|
|
|
- return new Queue(QUEUE_B, true);
|
|
|
+ return new Queue(QUEUE_SETTLE, true);
|
|
|
}
|
|
|
@Bean
|
|
|
- public Binding bindingB(){
|
|
|
- return BindingBuilder.bind(queueB()).to(fanoutExchange());
|
|
|
- }
|
|
|
+ public Binding binding() {
|
|
|
|
|
|
- /**
|
|
|
- * 获取队列B
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Bean
|
|
|
- public Queue queueC() {
|
|
|
- //队列持久
|
|
|
- return new Queue(QUEUE_C, true);
|
|
|
- }
|
|
|
- @Bean
|
|
|
- public Binding bindingC(){
|
|
|
- return BindingBuilder.bind(queueB()).to(topicExchange()).with(ROUTINGKEY_C);
|
|
|
+ return BindingBuilder.bind(queueConfirm()).to(directExchange()).with(RabbitConfig.ROUTINGKEY_CONFIRM);
|
|
|
}
|
|
|
}
|