feat: Redis Stream Spring Boot starter 首次提交
封装 Redis Streams 收发,零业务依赖。含自动装配、发送模板、监听容器、 autoclaim 崩溃恢复+死信淘汰、stream 定时裁剪、gzip 编解码、环境隔离。 本次随提交的改进: - per-handler 重试次数:getMaxRetryTimes() 覆写生效,全局 redis-stream.max-retry 兜底 - 死信回调传入反序列化后的业务消息(saveExceptionFromFields) - pom 升级 maven-surefire-plugin 至 2.22.2,使 JUnit 5 测试真正执行 - 集成测试连接信息改为 -D 注入(默认 localhost:6379),凭据不入代码 - lombok 改为 optional,不污染下游依赖 - 新增 README 使用文档 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.njcn.middle.stream.autoconfig;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
class RedisStreamPropertiesTest {
|
||||
|
||||
@Test
|
||||
void hasSaneDefaults() {
|
||||
RedisStreamProperties p = new RedisStreamProperties();
|
||||
assertFalse(p.isEnvIsolation(), "envIsolation 默认 false");
|
||||
assertEquals("", p.getEnv(), "env 默认空串");
|
||||
assertEquals("", p.getConsumerName(), "consumerName 默认空串");
|
||||
assertEquals(10, p.getReadCount(), "readCount 默认 10");
|
||||
assertEquals(2000L, p.getBlockMs(), "blockMs 默认 2000");
|
||||
assertEquals(3, p.getMaxRetry(), "maxRetry 默认 3");
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoclaimHasDefaults() {
|
||||
RedisStreamProperties.Autoclaim a = new RedisStreamProperties().getAutoclaim();
|
||||
assertNotNull(a, "autoclaim 默认非 null");
|
||||
assertEquals(60000L, a.getMinIdleMs(), "autoclaim.minIdleMs 默认 60000");
|
||||
assertEquals(30000L, a.getIntervalMs(), "autoclaim.intervalMs 默认 30000");
|
||||
}
|
||||
|
||||
@Test
|
||||
void trimHasDefaults() {
|
||||
RedisStreamProperties.Trim t = new RedisStreamProperties().getTrim();
|
||||
assertNotNull(t, "trim 默认非 null");
|
||||
assertEquals(60000L, t.getIntervalMs(), "trim.intervalMs 默认 60000");
|
||||
assertEquals(100000L, t.getMaxlen(), "trim.maxlen 默认 100000");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user