title: Expired key trigger event - Spring data Redis
body: <p>I am trying to setup a Key expiry event handler using spring data redis but am not able to make it work. I did some research but dint yeild expected results. Not sure what i am missing. I would like to LOG a message when the key on the redis cache expires. </p>
  
  <pre><code>@Configuration
  @EnableRedisRepositories
  public class RedisConfig {
  
      @Bean 
      StringRedisTemplate stringRedisTemplate(){
          StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(jedisConnectionFactory());
          return stringRedisTemplate;
      }
  
      @Bean
      RedisMessageListenerContainer redisContainer() {
          RedisMessageListenerContainer container 
            = new RedisMessageListenerContainer(); 
          container.setConnectionFactory(jedisConnectionFactory()); 
          container.addMessageListener(messageListener(), topic()); 
          return container; 
      }
  
      @Bean
      MessageListenerAdapter messageListener() { 
          return new MessageListenerAdapter(new RedisMessageSubscriber());
      }
  
      @Bean
      MessagePublisher redisPublisher() { 
          return new RedisMessagePublisher();
      }
  
      @Bean
      ChannelTopic topic() {
          return new ChannelTopic("messageQueue");
      }
  }
  
  
  public interface MessagePublisher {
      void publish(String message);
  }
  
  public class RedisMessagePublisher implements MessagePublisher {
  
      @Autowired
      private StringRedisTemplate stringRedisTemplate;
      @Autowired
      private ChannelTopic topic;
  
      public void publish(String message) {
          stringRedisTemplate.convertAndSend(topic.getTopic(), message);
      }
  }
  
  @Service
  public class RedisMessageSubscriber implements MessageListener {
  
      private static final Logger LOG = Logger.getLogger(RedisMessageSubscriber.class);
  
      public static List&lt;String&gt; messageList = new ArrayList&lt;String&gt;();
  
      @Override
      public void onMessage(Message message, byte[] pattern) {
          messageList.add(message.toString());
      }
  
  }
  </code></pre>
  
  <p>Can someone help?
  Thanks</p>