Jedis, Cannot get jedis connection: cannot get resource from pool
I moved from redis.template to plain jedis.
Added below configuration(can be added in redis template too) for pool and don't see any exception now:
jedisPoolConfig.setMaxIdle(30);
jedisPoolConfig.setMinIdle(10);
for redis template:
jedisConnectionFactory.getPoolConfig().setMaxIdle(30);
jedisConnectionFactory.getPoolConfig().setMinIdle(10);
Same above config can be added in redis template too.
Cannot get Jedis connection, nested exception: Could not get a resource from the pool
Your port numbers are misconfigured between properties and the self-configured connection factory.
I would recommend sticking with one or the other Spring Boot's RedisAutoconfiguration
which pulls in JedisConnectionConfiguration
will automatically create a ConnectionFactory
for you based of the properties.
https://github.com/spring-projects/spring-boot/blob/8f4bf233b4895a4fade5aff41e0a309f90ba3193/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java
Driven from the spring.redis
properties.
JedisConnectionException: Could not get a resource from the pool
Not sure what's the overload for your Factory but you're definitely missing the TLS flag.
See this: https://github.com/xetorthio/jedis/blob/master/src/test/java/redis/clients/jedis/tests/SSLJedisTest.java#L55
6380/TCP is TLS enabled in Azure Redis Cache. You can enable 6379/TCP from the Azure Portal for plain text connections or you can do the right thing.
Check out the official quickstart for Jedis with Azure Redis Cache (note the useSsl
flag) - https://docs.microsoft.com/en-us/azure/redis-cache/cache-java-get-started
JedisShardInfo shardInfo = new JedisShardInfo("
<name>.redis.cache.windows.net",
6380,
useSsl);
shardInfo.setPassword("<key>"); /* Use your access key. */
Jedis jedis = new Jedis(shardInfo);
jedis.set("foo", "bar");
String value = jedis.get("foo");
nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
I've posted answer here: Could not connect to Redis at 10.XX.XX.28:6379: Unknown error - while accessing from Spring Batch or windows machine.
The solutions works fine for me. It's just config changes nothing else.
Related Topics
How to Equal Two 2D Arrays Together in Java
How to Conditionally Enable or Disable Scheduled Jobs in Spring
How to Get Exponents Without Using the Math.Pow for Java
The Highest Even Number in a Array
How to Wait for All Threads to Finish, Using Executorservice
How to Know Which Tomcat Version Embedded in Spring Boot
Add Additional Rules to the Compare Method of a Comparator
Statefulbeantocsv With Column Headers
Password Encrypt and Decrypt Using Spring-Security
Random Number Generation Without Repetition in Java
Adding a Custom Http Header to a Spring Boot Ws Call (Wstemplate)
Autosize Column Width Using Poi
Selecting Specific Rows from Sqlite Database-Android-Sqlite Database
Check If Url Is Https or Http Protocol
Calling Mutiple Webservice At Same Time in Spring Java
Org.Hibernate.Annotationexception: @Onetoone or @Manytoone on <Entity> References an Unknown Entity