28 lines
984 B
Java
28 lines
984 B
Java
|
|
package com.tuoheng.machine.config;
|
||
|
|
|
||
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||
|
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Redis 配置类
|
||
|
|
* 用于配置 Redis Pub/Sub 相关的 Bean
|
||
|
|
*/
|
||
|
|
@Configuration
|
||
|
|
@ConditionalOnProperty(name = "machine.state.store.type", havingValue = "redis")
|
||
|
|
public class RedisConfig {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 创建 Redis 消息监听容器
|
||
|
|
* 用于 Redis Pub/Sub 功能
|
||
|
|
*/
|
||
|
|
@Bean
|
||
|
|
public RedisMessageListenerContainer redisMessageListenerContainer(
|
||
|
|
RedisConnectionFactory connectionFactory) {
|
||
|
|
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||
|
|
container.setConnectionFactory(connectionFactory);
|
||
|
|
return container;
|
||
|
|
}
|
||
|
|
}
|