I create a listener below
@Bean
public RedisMessageListenerContainer listenerContainer(JedisConnectionFactory factory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(factory);
Topic expiredTopic = new PatternTopic(this.expiredEvent);
ArrayList<Topic> topics = new ArrayList<>();
topics.add(expiredTopic);
container.addMessageListener(redisMessageListener, topics);
System.out.println("Get New listenerContainer");
return container;
}
properties:
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=localhost:6379,localhost:6380,localhost:6381
It looks great on the begining. But while I shutdown the master, redis vote a new master. My listener didnt work anymore (my cache is still good). I think the problem is "container.setConnectionFactory", but I have no idea how to fix this problem.
I try to add @Scope("prototype") but it didnt work.