0

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.

Joseph
  • 1
  • I use listenerContainer.getConnectionFactory and found that connectionfactory has changed. now I think problem is I didnt subscript every redis ? – Joseph Dec 08 '22 at 02:53

0 Answers0