bugfix:解决 Redis MQ 消息队列的类加载初始化问题

This commit is contained in:
YunaiV 2023-11-08 08:30:05 +08:00
parent 91832e2ae3
commit 95d5fc4a58

View File

@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
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;
@ -98,9 +99,20 @@ public class YudaoTenantAutoConfiguration {
// ========== MQ ==========
@Bean
public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() {
return new TenantRedisMessageInterceptor();
/**
* 多租户 Redis 消息队列的配置类
*
* 为什么要单独一个配置类呢如果直接把 TenantRedisMessageInterceptor Bean 的初始化放外面会报 RedisMessageInterceptor 类不存在的错误
*/
@Configuration
@ConditionalOnClass(name = "cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate")
public static class TenantRedisMQAutoConfiguration {
@Bean
public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() {
return new TenantRedisMessageInterceptor();
}
}
@Bean