diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/consumer/file/FileConfigRefreshConsumer.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/consumer/file/FileConfigRefreshConsumer.java index 671b41943..4a8dcd2bd 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/consumer/file/FileConfigRefreshConsumer.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/consumer/file/FileConfigRefreshConsumer.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.infra.mq.consumer.file; -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener; import cn.iocoder.yudao.module.infra.mq.message.file.FileConfigRefreshMessage; import cn.iocoder.yudao.module.infra.service.file.FileConfigService; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -15,14 +15,14 @@ import javax.annotation.Resource; */ @Component @Slf4j -public class FileConfigRefreshConsumer extends AbstractChannelMessageListener { +public class FileConfigRefreshConsumer { @Resource private FileConfigService fileConfigService; - @Override - public void onMessage(FileConfigRefreshMessage message) { - log.info("[onMessage][收到 FileConfig 刷新消息]"); + @EventListener + public void execute(FileConfigRefreshMessage message) { + log.info("[execute][收到 FileConfig 刷新消息]"); fileConfigService.initFileClients(); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/message/file/FileConfigRefreshMessage.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/message/file/FileConfigRefreshMessage.java index 7cc120de3..9e2336e30 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/message/file/FileConfigRefreshMessage.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/message/file/FileConfigRefreshMessage.java @@ -1,17 +1,19 @@ package cn.iocoder.yudao.module.infra.mq.message.file; -import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage; import lombok.Data; +import org.springframework.cloud.bus.event.RemoteApplicationEvent; /** * 文件配置数据刷新 Message */ @Data -public class FileConfigRefreshMessage extends AbstractChannelMessage { +public class FileConfigRefreshMessage extends RemoteApplicationEvent { - @Override - public String getChannel() { - return "infra.file-config.refresh"; + public FileConfigRefreshMessage() { + } + + public FileConfigRefreshMessage(Object source, String originService, String destinationService) { + super(source, originService, destinationService); } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/producer/file/FileConfigProducer.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/producer/file/FileConfigProducer.java index a666b185d..b06ab2d5c 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/producer/file/FileConfigProducer.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/mq/producer/file/FileConfigProducer.java @@ -1,26 +1,20 @@ package cn.iocoder.yudao.module.infra.mq.producer.file; -import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; +import cn.iocoder.yudao.framework.mq.core.bus.AbstractBusProducer; import cn.iocoder.yudao.module.infra.mq.message.file.FileConfigRefreshMessage; import org.springframework.stereotype.Component; -import javax.annotation.Resource; - /** * 文件配置相关消息的 Producer */ @Component -public class FileConfigProducer { - - @Resource - private RedisMQTemplate redisMQTemplate; +public class FileConfigProducer extends AbstractBusProducer { /** * 发送 {@link FileConfigRefreshMessage} 消息 */ public void sendFileConfigRefreshMessage() { - FileConfigRefreshMessage message = new FileConfigRefreshMessage(); - redisMQTemplate.send(message); + publishEvent(new FileConfigRefreshMessage(this, selfDestinationService(), selfDestinationService())); } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-dev.yaml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-dev.yaml index a3cf91658..a7c65af00 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-dev.yaml @@ -62,6 +62,15 @@ jasypt: encryptor: password: yuanma # 加解密的秘钥 +--- #################### MQ 消息队列相关配置 #################### +spring: + cloud: + stream: + rocketmq: + # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类 + binder: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址 + --- #################### 定时任务相关配置 #################### --- #################### 配置中心相关配置 #################### diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-local.yaml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-local.yaml index 77a41bd10..b3805ba9c 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-local.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application-local.yaml @@ -73,6 +73,15 @@ jasypt: encryptor: password: yuanma # 加解密的秘钥 +--- #################### MQ 消息队列相关配置 #################### +spring: + cloud: + stream: + rocketmq: + # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类 + binder: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址 + --- #################### 定时任务相关配置 #################### --- #################### 配置中心相关配置 #################### diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml index aa2d79805..a089dd6b4 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml @@ -52,6 +52,37 @@ dubbo: application: id: infra-server # TODO 一定要写么? +--- #################### MQ 消息队列相关配置 #################### + +spring: + cloud: + # Spring Cloud Stream 配置项,对应 BindingServiceProperties 类 + stream: + # function: + # definition: roleRefreshConsumer;roleMenuRefreshConsumer;userRoleRefreshConsumer; + # Binding 配置项,对应 BindingProperties Map + bindings: + roleRefresh-out-0: + destination: system_role_refresh + roleRefreshConsumer-in-0: + destination: system_role_refresh + group: system_role_refresh_consumer_group + # Spring Cloud Stream RocketMQ 配置项 + rocketmq: + # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类 + binder: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址 + default: # 默认 bindings 全局配置 + producer: # RocketMQ Producer 配置项,对应 RocketMQProducerProperties 类 + group: system_producer_group # 生产者分组 + send-type: SYNC # 发送模式,SYNC 同步 + + # Spring Cloud Bus 配置项,对应 BusProperties 类 + bus: + enabled: true # 是否开启,默认为 true + id: ${spring.application.name}:${server.port} # 编号,Spring Cloud Alibaba 建议使用“应用:端口”的格式 + destination: springCloudBus # 目标消息队列,默认为 springCloudBus + --- #################### 芋道相关配置 #################### yudao: diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/application-dev.yaml b/yudao-module-system/yudao-module-system-biz/src/main/resources/application-dev.yaml index b556d07b2..11e6d04c5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/application-dev.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/application-dev.yaml @@ -62,6 +62,15 @@ jasypt: encryptor: password: yuanma # 加解密的秘钥 +--- #################### MQ 消息队列相关配置 #################### +spring: + cloud: + stream: + rocketmq: + # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类 + binder: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址 + --- #################### 定时任务相关配置 #################### --- #################### 服务保障相关配置 #################### diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/application-local.yaml b/yudao-module-system/yudao-module-system-biz/src/main/resources/application-local.yaml index 917e6d73a..2a58d430b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/application-local.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/application-local.yaml @@ -72,6 +72,15 @@ jasypt: encryptor: password: yuanma # 加解密的秘钥 +--- #################### MQ 消息队列相关配置 #################### +spring: + cloud: + stream: + rocketmq: + # RocketMQ Binder 配置项,对应 RocketMQBinderConfigurationProperties 类 + binder: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv 地址 + --- #################### 定时任务相关配置 #################### --- #################### 服务保障相关配置 #################### diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml b/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml index 0003cb5e6..053c93d8f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/application.yaml @@ -79,7 +79,7 @@ spring: bus: enabled: true # 是否开启,默认为 true id: ${spring.application.name}:${server.port} # 编号,Spring Cloud Alibaba 建议使用“应用:端口”的格式 - destination: springCloudBus2 # 目标消息队列,默认为 springCloudBus + destination: springCloudBus # 目标消息队列,默认为 springCloudBus --- #################### 芋道相关配置 ####################