-
Type: Improvement
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: QualifiedToSchedule
-
Component/s: Cache, Notifications
-
Epic Link:
In cluster mode, it might be useful, for every node to be able to register to a notification channel, in order to be able to broadcast messages.
Connect cluster has implemented a Redis Pub/Sub channel, for such notification, see GitCacheServiceCluster class.
It is based on:
- Nuxeo RedisExecutor class, to benefit from Nuxeo interface to the Redis server.
- Subscription to the channel:
protected void subscribeToRedis(RedisExecutor redisExecutor) { try { log.info("Subscribing to Redis channel: " + CHANNEL); redisExecutor.execute(new RedisCallable<Object>() { @Override public Object call(Jedis jedis) throws Exception { jedis.subscribe(new JedisPubSub() { @Override public void onSubscribe(String channel, int subscribedChannels) { super.onSubscribe(channel, subscribedChannels); if (subscribtionLatch != null) { subscribtionLatch.countDown(); } } @Override public void onMessage(String channel, String message) { if (CHANNEL.equals(channel)) { log.debug("Receive message: " + message); GitCacheServiceClusterEvent event; try { event = GitCacheServiceClusterEvent.fromJSON(message); log.debug("Event read: " + event); handleRedisEvent(event); } catch (IOException e) { log.error("Error while parsing the message", e); } } } }, CHANNEL); return null; } });
- Publishing a message
RedisExecutor redisExecutor = Framework.getService(RedisExecutor.class); redisExecutor.execute(new RedisCallable<Object>() { @Override public Object call(Jedis jedis) throws Exception { String json = event.toJSON(); return jedis.publish(CHANNEL, json); } });
- is required by
-
NXP-20813 RedisCache should use a local cache
- Open