Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug-RedisBroadcastManager-v2.7.0.M1 #674

Closed
jxplus opened this issue Jun 14, 2022 · 8 comments
Closed

Bug-RedisBroadcastManager-v2.7.0.M1 #674

jxplus opened this issue Jun 14, 2022 · 8 comments

Comments

@jxplus
Copy link

jxplus commented Jun 14, 2022

    @Override
    public CacheResult publish(CacheMessage message) {
        Object jedisObj = null;
        try {
            jedisObj = writeCommands();
           // error line
            byte[] value = config.getValueEncoder().apply(message);
            if (jedisObj instanceof Jedis) {
                ((Jedis) jedisObj).publish(channel, value);
            } else {
                ((UnifiedJedis) jedisObj).publish(channel, value);
            }
            return CacheResult.SUCCESS_WITHOUT_MSG;
        } catch (Exception ex) {
            logError("PUBLISH", "N/A", ex);
            return new CacheResult(ex);
        } finally {
            closeJedis(jedisObj);
        }
    }

RedisBroadcastManager中上面这个方法,config.getValueEncoder().apply(message);这个报错,ParseFunction的apply()方法没有实现的。
这里我看是ExternalCacheAutoInit里设置的。

@areyouok
Copy link
Collaborator

fixed

@areyouok
Copy link
Collaborator

如果还有问题,可重新打开

@jxplus
Copy link
Author

jxplus commented Jun 14, 2022

@areyouok 只是替换keyConvertor不够吧,还得换掉valueDecoder。用经过cacheContext处理过的cache对象,或者直接用configProvider转换都行好像。
另外,这个RedisBroadcastManager里的runSubThread()方法,无限循环一直在创建新连接,感觉不用循环吧,调一次subscribe不就够了吗?

@areyouok
Copy link
Collaborator

只做缓存失效,所以通知消息里面不传递value。

subscribe是堵塞的,如果不发生异常,不会不停的创建,放在循环里面是为了做异常兜底。

@jxplus
Copy link
Author

jxplus commented Jun 14, 2022

有道理

@jxplus
Copy link
Author

jxplus commented Jun 14, 2022

不过我本地试的时候,subscribe会报错,报错内容是该channel已经subscribe,我使用的是connectionFactory.getConnection().subscribe()

@jxplus
Copy link
Author

jxplus commented Jun 14, 2022

value不传递的问题,貌似只是要复用jetcache的序列化,来序列化CacheMessage对象,对象的value属性确实是null的,所以还是需要使用到ValueEncoder和Decoder。

@areyouok
Copy link
Collaborator

你说的对,我看花了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants