DATAREDIS-1093 - Document that Master/Replica connections do not support Pub/Sub.

This commit is contained in:
Mark Paluch
2020-02-13 11:55:44 +01:00
parent 1c7780380d
commit 0f609ad7f4
4 changed files with 29 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
* Master / Replica configuration to nodes know to not change address. Eg. when connecting to
* <a href="https://aws.amazon.com/documentation/elasticache/">AWS ElastiCache with Read Replicas</a>. <br/>
* Note: Redis is undergoing a nomenclature change where the term replica is used synonymously to slave.
* Please also note that a Master/Replica connection cannot be used for Pub/Sub operations.
*
* @author Mark Paluch
* @author Christoph Strobl

View File

@@ -22,6 +22,7 @@ import io.lettuce.core.api.StatefulConnection;
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.masterreplica.MasterReplica;
import io.lettuce.core.masterreplica.StatefulRedisMasterReplicaConnection;
import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
import java.util.Collection;
import java.util.Optional;
@@ -70,6 +71,10 @@ class StaticMasterReplicaConnectionProvider implements LettuceConnectionProvider
@Override
public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) {
if (connectionType.equals(StatefulRedisPubSubConnection.class)) {
throw new UnsupportedOperationException("Pub/Sub connections not supported with Master/Replica configurations");
}
if (StatefulConnection.class.isAssignableFrom(connectionType)) {
StatefulRedisMasterReplicaConnection<?, ?> connection = MasterReplica.connect(client, codec, nodes);