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

Redis pub/sub connection give connection closed error with lettuce

$
0
0

This method publishes the message and also gets connection closed error constantly in calling publish message method. And for some of the instances for which i am getting this error after checking the logs found out that for those instances the message was pushed and also consumed.

public void pubSubInit() {        try {            ClusterTopologyRefreshOptions clusterTopologyRefreshOptions = ClusterTopologyRefreshOptions.builder()                    .enablePeriodicRefresh(Duration.ofSeconds(30))                    .enableAllA daptiveRefreshTriggers()                    .build();            SocketOptions socketOptions = SocketOptions.builder()                    .keepAlive(true)                    .build();            ClusterClientOptions clusterClientOptions = ClusterClientOptions.builder()                    .socketOptions(socketOptions)                    .topologyRefreshOptions(clusterTopologyRefreshOptions)                    .validateClusterNodeMembership(false)                    .autoReconnect(true)                    .build();            redisPubSubClusterClient = RedisClusterClient.create("redis://" + redisUrl);            redisPubSubClusterClient.setOptions(clusterClientOptions);            StatefulRedisClusterPubSubConnection<String, String> connection                    = redisPubSubClusterClient.connectPubSub();            connection.addListener(new ClusterRedisListener(redisMessageHandler));            RedisPubSubAsyncCommands<String, String> async                    = connection.async();            async.subscribe(channel1, channel2);        } catch (Exception e) {            LoggerUtil.error(CLASSNAME, e.getMessage(), Optional.empty());        }    }

publish message

public void publishMessage(String topic, String message) {        try (StatefulRedisClusterPubSubConnection<String, String> connection = redisPubSubClusterClient.connectPubSub()) {            RedisPubSubAsyncCommands<String, String> async = connection.async();            async.publish(topic, message);        } catch (Exception e) {            LoggerUtil.error(CLASSNAME, e.getMessage(), Optional.empty());        }    }

Exception Stack trace

Connection closedDefaultEndpoint.java in notifyDrainQueuedCommands at line 572CommandHandler.java in channelInactive at line 314PubSubCommandHandler.java in channelInactive at line 79AbstractChannelHandlerContext.java in invokeChannelInactive at line 260AbstractChannelHandlerContext.java in invokeChannelInactive at line 246AbstractChannelHandlerContext.java in fireChannelInactive at line 239ChannelInboundHandlerAdapter.java in channelInactive at line 81ChannelGroupListener.java in channelInactive at line 46AbstractChannelHandlerContext.java in invokeChannelInactive at line 260AbstractChannelHandlerContext.java in invokeChannelInactive at line 246AbstractChannelHandlerContext.java in fireChannelInactive at line 239ChannelInboundHandlerAdapter.java in channelInactive at line 81PlainChannelInitializer.java in channelInactive at line 85AbstractChannelHandlerContext.java in invokeChannelInactive at line 260AbstractChannelHandlerContext.java in invokeChannelInactive at line 246AbstractChannelHandlerContext.java in fireChannelInactive at line 239DefaultChannelPipeline.java in channelInactive at line 1405AbstractChannelHandlerContext.java in invokeChannelInactive at line 260AbstractChannelHandlerContext.java in invokeChannelInactive at line 246DefaultChannelPipeline.java in fireChannelInactive at line 901AbstractChannel.java in run at line 818SpanInScopeRunnableWrapper.java in run at line 64AbstractEventExecutor.java in safeExecute at line 164SingleThreadEventExecutor.java in runAllTasks at line 472NioEventLoop.java in run at line 500SingleThreadEventExecutor.java in run at line 989ThreadExecutorMap.java in run at line 74FastThreadLocalRunnable.java in run at line 30Thread.java in run at line 748

Viewing all articles
Browse latest Browse all 2204

Trending Articles



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