title: Spring-Boot 2.7 Redis PUB/SUB fails startup on missing Redis connection
body: <p>I have this configuration for my pub/sub implementation:</p>
  <pre><code>@Bean
  public RedisMessageListenerContainer container(LettuceConnectionFactory connectionFactory,
                                                 MessageListenerAdapter listenerAdapter) {
  
      RedisMessageListenerContainer container = new RedisMessageListenerContainer();
      container.setConnectionFactory(connectionFactory);
      container.addMessageListener(listenerAdapter, new ChannelTopic(publishChannel));
      return container;
  }
  
  @Bean
  public MessageListenerAdapter listenerAdapter(RedisReceiver receiver) {
      return new MessageListenerAdapter(receiver, &quot;receiveMessage&quot;);
  }
  
  @Bean
  public StringRedisTemplate template(LettuceConnectionFactory connectionFactory) {
      return new StringRedisTemplate(connectionFactory);
  }
  </code></pre>
  <p>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:</p>
  <blockquote>
  <p>Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean '<strong>container</strong>'; 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</p>
  </blockquote>
  <p>(&quot;<strong>container</strong>&quot; is the Bean at the top in my code snippet)</p>
  <p>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?</p>
  <p>UPDATE:</p>
  <p>Did some digging and this part of the code is the culprit:</p>
  <p><a href="https://github.com/spring-projects/spring-data-redis/blob/main/src/main/java/org/springframework/data/redis/listener/RedisMessageListenerContainer.java#L1169" rel="nofollow noreferrer">https://github.com/spring-projects/spring-data-redis/blob/main/src/main/java/org/springframework/data/redis/listener/RedisMessageListenerContainer.java#L1169</a></p>
  <p>In comparison to the 2.6.x branch, where this was inside a try/catch (not sure though as it seems to be a completely different implementation), it is missing in version 2.7.</p>