Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2222

How to listen for keyspace notifications of redis cluster in java using jedis client?

$
0
0

I am setting a server which can listen and send message about any event occur in the redis database. I am successful in getting notified about new events for redis host and port but not able to do so for redis cluster.

GenericObjectPoolConfig config = new GenericObjectPoolConfig();config.setMaxTotal(30);config.setMaxWaitMillis(2000);Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();jedisClusterNode.add(new HostAndPort("127.0.0.1", 7001));JedisCluster cluster1 = new JedisCluster(jedisClusterNode, config);String redisProperties = cluster1.getClusterNodes().toString().replaceAll("[{}]", "");Set<HostAndPort> nodes = new HashSet<>();String[] mainArray = redisProperties.split(",");for (int i = 0; i < mainArray.length; i++) {    String[] equalArray = mainArray[i].split("=");    String mainData = equalArray[0];    String[] ipPortPair = mainData.split(":");    nodes.add(new HostAndPort(ipPortPair[0].trim(), Integer.valueOf(ipPortPair[1].trim())));}JedisCluster cluster = new JedisCluster(nodes, 10000, 1000, 1, config);jedis.configSet("notify-keyspace-events", "AKE"); // For all kind of eventsjedis.psubscribe(new KeyListenerCluster(), "__keyevent@0__:*");

I am able to perform every other operation in using the redis-cluster but not able to do one thing.

cluster.configSet("notify-keyspace-events", "AKE"); // For all kind of eventscluster.psubscribe(new KeyListenerCluster(), "__keyevent@0__:*");

Viewing all articles
Browse latest Browse all 2222

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>