- 应用骨架: Solon + MyBatis-Plus + PostgreSQL + Redis + Sa-Token - 核心链路: 回调网关 → 消息落库(幂等) → 分发队列(FOR UPDATE SKIP LOCKED) → worker消费/重试/死信 - 多租户隔离: 前缀法账号映射, 所有业务表带 tenant_id - 管理后台: FreeMarker 渲染, 租户/授权/队列/用量管理页面 - 历史消息补拉: 水位线驱动, getRoamMsg/getGroupMsg 增量拉取, 兜底回调丢失 - msg_key 统一算法(回调/补拉共享, 跨路径去重) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.6 KiB
Java
55 lines
1.6 KiB
Java
package com.imutil.common;
|
|
|
|
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
|
import org.noear.solon.annotation.Bean;
|
|
import org.noear.solon.annotation.Configuration;
|
|
import org.noear.solon.annotation.Inject;
|
|
import redis.clients.jedis.Jedis;
|
|
import redis.clients.jedis.JedisPool;
|
|
|
|
/**
|
|
* Redis 连接池配置
|
|
* <p>
|
|
* 读取 app.yml 的 imutil.redis.* 配置,构建 JedisPool 注册为 Solon Bean。
|
|
* 用于限流令牌桶、映射/授权缓存、补拉水位线等高频读写场景。
|
|
*
|
|
* @author imutil
|
|
*/
|
|
@Configuration
|
|
public class RedisConfig {
|
|
|
|
@Inject("${imutil.redis.host:localhost}")
|
|
private String host;
|
|
|
|
@Inject("${imutil.redis.port:6379}")
|
|
private int port;
|
|
|
|
@Inject("${imutil.redis.password:}")
|
|
private String password;
|
|
|
|
@Inject("${imutil.redis.database:0}")
|
|
private int database;
|
|
|
|
@Inject("${imutil.redis.timeout:2000}")
|
|
private int soTimeout;
|
|
|
|
@Inject("${imutil.redis.connectTimeout:2000}")
|
|
private int connectTimeout;
|
|
|
|
/**
|
|
* 构建 Jedis 连接池
|
|
*/
|
|
@Bean
|
|
public JedisPool jedisPool() {
|
|
GenericObjectPoolConfig<Jedis> config = new GenericObjectPoolConfig<>();
|
|
config.setMaxTotal(16);
|
|
config.setMaxIdle(8);
|
|
config.setMinIdle(2);
|
|
config.setTestWhileIdle(true);
|
|
config.setTimeBetweenEvictionRunsMillis(30_000);
|
|
// 空密码兼容:Postgres/Redis 无密码场景传 null,避免鉴权失败
|
|
String pwd = (password == null || password.isEmpty()) ? null : password;
|
|
return new JedisPool(config, host, port, connectTimeout, soTimeout, pwd, database, null);
|
|
}
|
|
}
|