Amazon-Elasticache [SOLVED]: SpringBoot Elasticache JedisMovedDataException: MOVED

Amazon-Elasticache [SOLVED]: SpringBoot Elasticache JedisMovedDataException: MOVED

Home Forums Amazon Web Services Amazon Elasticache Amazon-Elasticache [SOLVED]: SpringBoot Elasticache JedisMovedDataException: MOVED

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #205326

    Cloudy Point
    Keymaster

    QuestionQuestion

    Trying to use SpringBoot with SpringData with Elasticache:

    application.properties:

    spring.redis.host=XXXX-dev.XXXX.clusXXXcfg.XXX.cache.amazonaws.com
    spring.redis.port=6379
    

    CacheConfiguration:

    @Configuration
    @PropertySource("classpath:application.properties")
    public class CacheConfiguration {
    
    
    @Value("${spring.redis.host}")
    private String redisHostName;
    
    @Bean
    public RedisTemplate<String, Company> redisTemplate() {
        RedisTemplate<String, Company> template = new RedisTemplate();
        template.setConnectionFactory(jedisConnectionFactory());
        return template;
    }
    
    @Bean
    JedisConnectionFactory jedisConnectionFactory() {
        JedisConnectionFactory factory = new JedisConnectionFactory();
        factory.setHostName(redisHostName);
        factory.setUsePool(true);
        return factory;
    }
    
    
    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }
    

    }

    Service call:

    @Autowired
    RedisTemplate<String, Company> redisTemplate;
    
    private ValueOperations valueOperations;
    
    @PostConstruct
    private void init() {
        valueOperations = redisTemplate.opsForValue();
    }
    
    @Override
    public String createOtp(Company company) {
        String token = UUID.randomUUID().toString();
        valueOperations.set(token, company);
        valueOperations.getOperations().expire(token, 5, TimeUnit.MINUTES);
        return token;
    }
    

    Error:

    org.springframework.data.redis.ClusterRedirectException: Redirect: slot 7228 to 10...:6379.*

    redis.clients.jedis.exceptions.JedisMovedDataException: MOVED 7228 10...:6379.*

    The question is – what is wrong with configuration?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.