Skip to content

Commit

Permalink
Pub/Sub resubscribe failures on connection activation #1201
Browse files Browse the repository at this point in the history
Lettuce now logs failures of asynchronously fired commands during connection activation.
  • Loading branch information
mp911de committed Jan 13, 2020
1 parent b193839 commit 1fed2f8
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.util.List;

import io.lettuce.core.RedisChannelWriter;
import io.lettuce.core.RedisCommandExecutionException;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.StatefulRedisConnectionImpl;
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.protocol.ConnectionWatchdog;
import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands;
import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
import io.netty.util.internal.logging.InternalLoggerFactory;

/**
* An thread-safe pub/sub connection to a Redis server. Multiple threads may share one {@link StatefulRedisPubSubConnectionImpl}
Expand All @@ -40,8 +42,8 @@
* @param <V> Value type.
* @author Mark Paluch
*/
public class StatefulRedisPubSubConnectionImpl<K, V> extends StatefulRedisConnectionImpl<K, V> implements
StatefulRedisPubSubConnection<K, V> {
public class StatefulRedisPubSubConnectionImpl<K, V> extends StatefulRedisConnectionImpl<K, V>
implements StatefulRedisPubSubConnection<K, V> {

private final PubSubEndpoint<K, V> endpoint;

Expand Down Expand Up @@ -141,6 +143,13 @@ private <T> T[] toArray(Collection<T> c) {
@Override
public void activated() {
super.activated();
resubscribe();
for (RedisFuture<Void> command : resubscribe()) {
command.exceptionally(throwable -> {
if (throwable instanceof RedisCommandExecutionException) {
InternalLoggerFactory.getInstance(getClass()).warn("Re-subscribe failed: " + command.getError());
}
return null;
});
}
}
}

0 comments on commit 1fed2f8

Please sign in to comment.