添加redis配置文件
This commit is contained in:
parent
a17809909d
commit
f41a8d6ddd
|
|
@ -0,0 +1,28 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,28 @@
|
|||
spring:
|
||||
application:
|
||||
name: thingsboard-client-demo
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
database: 0
|
||||
timeout: 3000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
max-wait: -1ms
|
||||
|
||||
# 机器状态存储配置
|
||||
# memory: 使用内存存储(单节点部署,默认)
|
||||
# redis: 使用 Redis 存储(多节点部署)
|
||||
machine:
|
||||
state:
|
||||
store:
|
||||
type: memory
|
||||
sn:
|
||||
repository:
|
||||
type: memory
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
|
|
|||
Loading…
Reference in New Issue