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

Spring-Boot 2.7 Redis PUB/SUB fails startup on missing Redis connection

$
0
0

I have this configuration for my pub/sub implementation:

@Beanpublic RedisMessageListenerContainer container(LettuceConnectionFactory connectionFactory,                                               MessageListenerAdapter listenerAdapter) {    RedisMessageListenerContainer container = new RedisMessageListenerContainer();    container.setConnectionFactory(connectionFactory);    container.addMessageListener(listenerAdapter, new ChannelTopic(publishChannel));    return container;}@Beanpublic MessageListenerAdapter listenerAdapter(RedisReceiver receiver) {    return new MessageListenerAdapter(receiver, "receiveMessage");}@Beanpublic StringRedisTemplate template(LettuceConnectionFactory connectionFactory) {    return new StringRedisTemplate(connectionFactory);}

This code worked fine until I updated to Spring-Boot 2.7 (previously 2.6.7).Now this code throws the following error on startup, when my Redis is not running:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'container'; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost/:6379

("container" is the Bean at the top in my code snippet)

Where or how can I configure that it catches the thrown exception on startup and just retries it again until the connection to Redis is available?


Viewing all articles
Browse latest Browse all 2204

Trending Articles



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