From c9392af4948e06e67f2d802eddb1941a0b591a89 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 14 Jun 2026 00:25:23 +0800 Subject: [PATCH] fix(tenant): 按需注册多租户 MQ 配置 --- yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java index 485e1aa..0a79468 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java @@ -30,6 +30,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.data.redis.cache.BatchStrategies; import org.springframework.data.redis.cache.RedisCacheConfiguration; @@ -155,28 +156,37 @@ public class YudaoTenantAutoConfiguration { // ========== MQ ========== - @Bean - public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() { - return new TenantRedisMessageInterceptor(); + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(name = "cn.iocoder.yudao.framework.mq.redis.core.interceptor.RedisMessageInterceptor") + public static class TenantRedisMQConfiguration { + + @Bean + public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() { + return new TenantRedisMessageInterceptor(); + } + } - @Bean + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(name = "org.springframework.amqp.rabbit.core.RabbitTemplate") - public TenantRabbitMQInitializer tenantRabbitMQInitializer() { - return new TenantRabbitMQInitializer(); + public static class TenantRabbitMQConfiguration { + + @Bean + public TenantRabbitMQInitializer tenantRabbitMQInitializer() { + return new TenantRabbitMQInitializer(); + } + } - @Bean + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(name = "org.apache.rocketmq.spring.core.RocketMQTemplate") - public TenantRocketMQInitializer tenantRocketMQInitializer() { - return new TenantRocketMQInitializer(); - } + public static class TenantRocketMQConfiguration { - // ========== Job ========== + @Bean + public TenantRocketMQInitializer tenantRocketMQInitializer() { + return new TenantRocketMQInitializer(); + } - @Bean - public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) { - return new TenantJobAspect(tenantFrameworkService); } // ========== Redis ========== @@ -200,4 +210,17 @@ public class YudaoTenantAutoConfiguration { return cacheManager; } + // ========== Job ========== + + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(name = "com.xxl.job.core.context.XxlJobContext") + public static class TenantJobConfiguration { + + @Bean + public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) { + return new TenantJobAspect(tenantFrameworkService); + } + + } + } -- libgit2 0.21.4