潘志宝
2024-09-06 c06f48bded461209f117167fbf89ed57a3f37ef4
提交 | 用户 | 时间
e7c126 1 package com.iailab.framework.mq.redis.config;
H 2
3 import com.iailab.framework.mq.redis.core.RedisMQTemplate;
4 import com.iailab.framework.mq.redis.core.interceptor.RedisMessageInterceptor;
5 import com.iailab.framework.redis.config.IailabRedisAutoConfiguration;
6 import lombok.extern.slf4j.Slf4j;
7 import org.springframework.boot.autoconfigure.AutoConfiguration;
8 import org.springframework.context.annotation.Bean;
9 import org.springframework.data.redis.core.StringRedisTemplate;
10
11 import java.util.List;
12
13 /**
14  * Redis 消息队列 Producer 配置类
15  *
16  * @author iailab
17  */
18 @Slf4j
19 @AutoConfiguration(after = IailabRedisAutoConfiguration.class)
20 public class IailabRedisMQProducerAutoConfiguration {
21
22     @Bean
23     public RedisMQTemplate redisMQTemplate(StringRedisTemplate redisTemplate,
24                                            List<RedisMessageInterceptor> interceptors) {
25         RedisMQTemplate redisMQTemplate = new RedisMQTemplate(redisTemplate);
26         // 添加拦截器
27         interceptors.forEach(redisMQTemplate::addInterceptor);
28         return redisMQTemplate;
29     }
30
31 }