From dd0833ef33804b7cf085b8c3c005e5788a3617d6 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Mon, 22 Mar 2021 17:10:38 +0800
Subject: [PATCH] 积分商城16
---
zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java b/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
index a1dac18..0993a3f 100644
--- a/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
+++ b/zq-erp/src/main/java/com/matrix/config/RabbitMqConfig.java
@@ -36,7 +36,12 @@
public static final String MQ_EXCHANGE_A = "hive_exchange_A";
//订阅模式
- public static final String MQ_EXCHANGE_FANOUT = "hive_exchange_fanout";
+ public static final String MQ_EXCHANGE_TOPIC = "hive_exchange_fanout";
+
+ @Bean
+ ScoreOrderTask ScoreOrderTask() {
+ return new ScoreOrderTask();
+ }
@Bean
VipCreateTask VipCreateTask() {
@@ -46,6 +51,14 @@
@Bean
OrderTask OrderrCreateTask() {
return new OrderTask();
+ }
+ @Bean
+ SalesOrderTask SalesOrderTask() {
+ return new SalesOrderTask();
+ }
+ @Bean
+ SalesOrderRefundTask SalesOrderRefundTask() {
+ return new SalesOrderRefundTask();
}
@Bean
@@ -71,17 +84,25 @@
//声明一个交换机
rabiitMqTemplate.exchangeDeclare(MQ_EXCHANGE_A+evn, "direct");
- rabiitMqTemplate.exchangeDeclare(MQ_EXCHANGE_FANOUT+evn, "fanout");
+ rabiitMqTemplate.exchangeDeclare(MQ_EXCHANGE_TOPIC +evn, "topic");
List<MqTask> taskList = new ArrayList<>();
//注册RabbitMq任务
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.CREATE_VIP + evn, MQTaskRouting.CREATE_VIP + evn, VipCreateTask()));
//订阅模式
- taskList.add(new MqTask(MQ_EXCHANGE_FANOUT + evn, MQTaskRouting.CREATE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,OrderrCreateTask()));
+
+
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_TEMPLATE_MSG + evn,MQTaskRouting.SEND_TEMPLATE_MSG + evn, TemplateMsgTask()));
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.ORDER_OUT_SOTORE + evn,MQTaskRouting.ORDER_OUT_SOTORE + evn, OrderOutSotoreTask()));
taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn,MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, UniformMsgSentTask()));
+ taskList.add(new MqTask(MQ_EXCHANGE_A + evn, MQTaskRouting.SHOP_ORDER_REFUND + evn,MQTaskRouting.SHOP_ORDER_REFUND + evn, SalesOrderRefundTask()));
+
+ //不同任务在不同的队列,但是routingKey一样则可以收到生产者消息
+ taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.CREATE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,SalesOrderTask()));
+ taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.SALES_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,OrderrCreateTask()));
+ taskList.add(new MqTask(MQ_EXCHANGE_TOPIC + evn, MQTaskRouting.SCORE_ORDER + evn,MQTaskRouting.CREATE_ORDER + evn,ScoreOrderTask()));
+
rabiitMqTemplate.binding(taskList);
--
Gitblit v1.9.1