Only unsubscribe from keyspace notifications if the node has the slot

This commit is contained in:
Chris Eager authored and Chris Eager committed 2022-07-26 09:21:50 -07:00
1 parent d290aad27b
commit bc02fe3831
1 file changed
+6 -3
@@ -330,9 +330,12 @@ public class MessagesCache extends RedisClusterPubSubAdapter<String, String> imp
}
private void unsubscribeFromKeyspaceNotifications(final String queueName) {
pubSubConnection.usePubSubConnection(connection -> connection.sync().upstream()
.commands()
.unsubscribe(getKeyspaceChannels(queueName)));
final int slot = SlotHash.getSlot(queueName);
pubSubConnection.usePubSubConnection(
connection -> connection.sync().nodes(node -> node.is(RedisClusterNode.NodeFlag.UPSTREAM) && node.hasSlot(slot))
.commands()
.unsubscribe(getKeyspaceChannels(queueName)));
}
private static String[] getKeyspaceChannels(final String queueName) {