My setup as follows:
- I am running this setup on the spring application.
- I am using the lettuce module's RedisAsyncCommands. I was able to run it using a stand-alone Redis config.
- When I try to run it using the sentinel mode it's getting stuck during the initial spring bootup process.
- I am able to hit the same sentinel using manual object creation in a terminal application. But it fails when I try in spring boot.
below is the stage where it gets stuck.
2021-06-25 02:48:57,328 38486 [main] INFO [i.l.c.EpollProvider] {{clusterName,default}{appResourceId,ss@dev}} - Starting without optional epoll library
2021-06-25 02:48:57,331 38489 [main] INFO [i.l.c.KqueueProvider] {{clusterName,default}{appResourceId,ss@dev}} - Starting without optional kqueue library
I have debugged it closely and it looks like the issue is coming while it's trying to connect to the sentinel server. It's trying to call the AbstractRedisClient class and not able to make a connection.
protected <T> T getConnection(ConnectionFuture<T> connectionFuture) {
try {
return connectionFuture.get();
} catch (InterruptedException var3) {
Thread.currentThread().interrupt();
throw RedisConnectionException.create(connectionFuture.getRemoteAddress(), var3);
} catch (Exception var4) {
if (var4 instanceof ExecutionException) {
throw RedisConnectionException.create(connectionFuture.getRemoteAddress(), var4.getCause());
} else {
throw RedisConnectionException.create(connectionFuture.getRemoteAddress(), var4);
}
}
}
Fails at line coonectionFuture.get().
My bean configuration:
@Bean
public RedisClient redisClient() {
return RedisClient.create(RedisURI.builder()
.withSentinel("localhost", 26379)
.withSentinel("localhost", 5000)
.withSentinel("localhost", 5001)
.withSentinelMasterId("mymaster").build());
}
@Bean
public StatefulRedisConnection<String, String> statefulRedisConnection(final RedisClient redisClient) {
return redisClient.connect();
}
@Bean
public RedisAsyncCommands<String, String> redisAsyncCommands(
final StatefulRedisConnection<String, String> redisConnection
) {
return redisConnection.async();
}
I will be using the async object below to run commands like async.hget(), async.set() etc.
private final RedisClient redisClientNew;
private final StatefulRedisConnection<String, String> connection;
private final RedisAsyncCommands<String, String> async;
Any help is greatly appreciated and let me know any extra information if needed. Please do comment if you have any idea on this or if you can help me with the setup.