Closed zengyufei closed 6 months ago
谢谢反馈!
我测试了 情况如下:
目前解决方案时修改solon-parent的pom文件redisx.version为1.4.7
关于为什么redisx1.6.2不行 有待考察
或者与 jedis 的版本有关,现在 redisx 用的就是 jedis 5.0.2。我去研究下
我测试了一下。。。没有问题呀,都正常的。这是我的测试代码(如果同时有 jedis 依赖的话,要注意外冲突):
@Test
public void test_bus() throws Exception {
int count = 10;
CountDownLatch countDownLatch = new CountDownLatch(count);
//--- bus 使用
RedisBus bus = client.getBus();
//发消息 (如果没有订阅者,好像消息会白发)
Thread thread = new Thread(() -> {
//订阅消息(这个函数会卡住线程)
bus.subscribe((topic, message) -> {
System.out.println(topic + " = " + message);
countDownLatch.countDown();
}, "topic:test");
});
thread.start();
Thread.sleep(100);
for (int i = 0; i < count; i++) {
bus.publish("topic:test", "event-" + System.currentTimeMillis());
}
countDownLatch.await(2, TimeUnit.SECONDS);
assert countDownLatch.getCount() == 0;
}
4.2.3
是的 他引入的org.apdplat.word这个项目的使用的redis发布订阅功能 如果引入的jedis是5.0.2或者5.0.0都不行。4.2.3则可以。
所以具体是org.apdplat.word的兼容高版本jedis(word使用的是2.5.1)有问题 还是说jedis的兼容问题有问题有待考察
我测试了一下。。。没有问题呀,都正常的。这是我的测试代码(如果同时有 jedis 依赖的话,要注意外冲突):
@Test public void test_bus() throws Exception { int count = 10; CountDownLatch countDownLatch = new CountDownLatch(count); //--- bus 使用 RedisBus bus = client.getBus(); //发消息 (如果没有订阅者,好像消息会白发) Thread thread = new Thread(() -> { //订阅消息(这个函数会卡住线程) bus.subscribe((topic, message) -> { System.out.println(topic + " = " + message); countDownLatch.countDown(); }, "topic:test"); }); thread.start(); Thread.sleep(100); for (int i = 0; i < count; i++) { bus.publish("topic:test", "event-" + System.currentTimeMillis()); } countDownLatch.await(2, TimeUnit.SECONDS); assert countDownLatch.getCount() == 0; }
是的 如果自己测试时可以 但这个项目不行 必须要更换依赖的jedis
这个,应该就是 版本依赖的冲突问题了。。。。A 包,依赖了 jedis a 版本;B 包,依赖了 jedis b 版本。。。当同时引入 A 和 B 包时,就冲突了(a 与 b 版本不兼容)。。。。算是特殊情况
那我关掉了
ok,感谢两位!
测试demo源码下载地址
https://github.com/zengyufei/solon-demo-fenci
项目启动需要本地redis,或修改 word.local.conf 关于redis的配置
先上正常期望成功值,游览器 Ctrl+F 搜索到3个,正常
开启 solon Jredis 依赖后表现,游览器 Ctrl+F 搜索不到,排查是jredis订阅功能失效,发布正常
测试demo源码下载地址
https://github.com/zengyufei/solon-demo-fenci
项目启动需要本地redis,或修改 word.local.conf 关于redis的配置