Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Java Spring Boot Redis has occurred nested exception is java.util.concurrent.RejectedExecutionException: event executor terminated

$
0
0

My service is built with spring boot REST API with Redis.Some time face with error that logs:

nested exception is java.util.concurrent.RejectedExecutionException: event executor terminatedorg.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.util.concurrent.RejectedExecutionException: event executor terminatedat org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:53) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:43) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:270) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:799) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.setEx(LettuceStringCommands.java:232) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.connection.DefaultedRedisConnection.setEx(DefaultedRedisConnection.java:302) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.connection.DefaultStringRedisConnection.setEx(DefaultStringRedisConnection.java:1003) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.DefaultValueOperations$4.potentiallyUsePsetEx(DefaultValueOperations.java:268) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.DefaultValueOperations$4.doInRedis(DefaultValueOperations.java:261) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:256) ~[spring-data-redis-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]

I have researched and fixed it with lettuce pool solution. My config in application.yamlredis:

host: ${REDIS_HOST}  port: ${REDIS_PORT}  password: ${REDIS_PASSWORD}  cachePrefix: ${spring.application.name}  defaultExpiration: 300  lettuce:    pool:      maxActive: ${REDIS_POOL_ACTIVE:40}      maxIdle: ${REDIS_POOL_MAX_IDLE:40}      minIdle: ${REDIS_POOL_MIN_IDLE:4}

My configuration Redis class

@EnableCaching@Configuration@EnableConfigurationPropertiespublic class RedisConfiguration extends CachingConfigurerSupport {    @Autowired    private  RedisConnectionFactory redisConnectionFactory;    @Primary    @Bean    public RedisExpireProperties expireProperties() {        return new RedisExpireProperties();    }    @Bean    public RedisCacheManager redisCacheManager(LettuceConnectionFactory lettuceConnectionFactory,                                               RedisExpireProperties expireProperties) {        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()                .disableCachingNullValues()                .entryTtl(Duration.ofSeconds(expireProperties.getDefaultExpiration()))                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json()));        if (StringUtils.isNotBlank(expireProperties.getCachePrefix())) {            String cachePrefix = "." + expireProperties.getCachePrefix() +":";            redisCacheConfiguration.prefixKeysWith(cachePrefix);            redisCacheConfiguration.usePrefix();        }        return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(lettuceConnectionFactory)                .cacheDefaults(redisCacheConfiguration).build();    }    @Bean    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();        redisTemplate.setConnectionFactory(redisConnectionFactory);        redisTemplate.setKeySerializer(new StringRedisSerializer());        return redisTemplate;    }

But This error still appears. Please suggest for me a new solution to resolve the error.Many thanks!


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>