feat(trademark): 实现商标筛查功能并优化相关配置
- 新增商标筛查进度展示界面与交互逻辑 - 实现产品、品牌及平台跟卖许可的分项任务进度追踪 - 添加商标数据导出与任务重试、取消功能 - 调整Redis连接池配置以提升并发性能 - 禁用ChromeDriver预加载,改为按需启动以节省资源- 支持品牌商标远程筛查接口调用与结果解析 - 增加Hutool工具库依赖用于简化IO与Excel处理- 更新USPTO商标查询脚本实现自动化检测 - 修改Ruoyi后台Redis依赖版本并添加集群心跳配置- 切换本地开发环境API地址指向内网测试服务器
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.ruoyi.framework.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import io.lettuce.core.ClientOptions;
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
import io.lettuce.core.resource.DefaultClientResources;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Redis连接池优化配置
|
||||
* 解决Lettuce连接超时问题
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisPoolConfig {
|
||||
|
||||
/**
|
||||
* 配置Lettuce客户端,启用心跳检测和自动重连
|
||||
*/
|
||||
@Bean
|
||||
public ClientResources clientResources() {
|
||||
return DefaultClientResources.builder()
|
||||
.ioThreadPoolSize(4) // IO线程数
|
||||
.computationThreadPoolSize(4) // 计算线程数
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化Redis连接池配置
|
||||
*/
|
||||
@Bean
|
||||
public LettucePoolingClientConfiguration lettucePoolConfig(ClientResources clientResources) {
|
||||
GenericObjectPoolConfig<?> poolConfig = new GenericObjectPoolConfig<>();
|
||||
poolConfig.setMaxTotal(50); // 最大连接数
|
||||
poolConfig.setMaxIdle(20); // 最大空闲连接
|
||||
poolConfig.setMinIdle(5); // 最小空闲连接
|
||||
poolConfig.setMaxWaitMillis(10000); // 获取连接最大等待时间
|
||||
|
||||
return LettucePoolingClientConfiguration.builder()
|
||||
.poolConfig(poolConfig)
|
||||
.clientResources(clientResources)
|
||||
.clientOptions(ClientOptions.builder()
|
||||
.autoReconnect(true) // 自动重连
|
||||
.pingBeforeActivateConnection(true) // 连接激活前ping检测
|
||||
.build())
|
||||
.commandTimeout(Duration.ofSeconds(10)) // 命令超时时间
|
||||
.shutdownTimeout(Duration.ofMillis(100)) // 关闭超时时间
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 定期检查Redis连接状态
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<Object, Object> optimizedRedisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
// 使用FastJson序列化器
|
||||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||
|
||||
// 设置序列化器
|
||||
template.setKeySerializer(new org.springframework.data.redis.serializer.StringRedisSerializer());
|
||||
template.setValueSerializer(serializer);
|
||||
template.setHashKeySerializer(new org.springframework.data.redis.serializer.StringRedisSerializer());
|
||||
template.setHashValueSerializer(serializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user