skip to Main Content

Today when I want to using Jedis to consume stream, throw this error:

java.lang.UnsupportedOperationException: Streams not supported using Jedis!
    at org.springframework.data.redis.connection.jedis.JedisConnection.streamCommands(JedisConnection.java:154) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.connection.DefaultedRedisConnection.xReadGroup(DefaultedRedisConnection.java:591) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.DefaultStreamOperations$4.inRedis(DefaultStreamOperations.java:310) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.DefaultStreamOperations$RecordDeserializingRedisCallback.doInRedis(DefaultStreamOperations.java:376) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.DefaultStreamOperations$RecordDeserializingRedisCallback.doInRedis(DefaultStreamOperations.java:371) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.core.DefaultStreamOperations.read(DefaultStreamOperations.java:305) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.stream.DefaultStreamMessageListenerContainer.lambda$getReadFunction$3(DefaultStreamMessageListenerContainer.java:236) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.stream.StreamPollTask.doLoop(StreamPollTask.java:138) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at org.springframework.data.redis.stream.StreamPollTask.run(StreamPollTask.java:123) ~[spring-data-redis-2.3.9.RELEASE.jar:2.3.9.RELEASE]
    at misc.config.async.pool.MdcTaskDecorator.lambda$decorate$0(MdcTaskDecorator.java:29) ~[classes/:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

I have search the docs that I know the Jedis is support Redis stream. Why did this still tell me did not support Redis Stream? This is my dependencies define in Gradle, this code force using 3.6.0 version of Jedis:

resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
              
                if (details.requested.group == 'redis.clients') {
                    details.useVersion "3.6.0"
                }
                
            }
        }

this code import Jedis:

api ("org.springframework.boot:spring-boot-starter-data-redis") {
            exclude group: "io.lettuce", module: "lettuce-core"
            exclude group: "redis.clients", module: "jedis"
        }
        api "redis.clients:jedis:3.6.0"

what should I do to avoid this problem? I tried this way to upgrade my spring data version like this:

api ("org.springframework.boot:spring-boot-starter-data-redis") {
            exclude group: "io.lettuce", module: "lettuce-core"
            exclude group: "org.springframework.data", module: "spring-data-redis"
        }
        api "org.springframework.data:spring-data-redis:2.5.0"

seems would cause other compatiable problem. And now I am using 2.3.10.RELEASE is already the newest version of spring boot 2.3.x. Should I upgrade to 2.4.x? If I upgrade to spring boot 2.4.x, there is no compatiable stable spring cloud version to match.

2

Answers


  1. Chosen as BEST ANSWER

    If you do not want to ugprade your spring version, then tried to upgrade spring-data-redis to version 2.5.0,step 1: do not using the default spring data:

    api ("org.springframework.boot:spring-boot-starter-data-redis") {
                exclude group: "io.lettuce", module: "lettuce-core"
                exclude group: "org.springframework.data", module: "spring-data-redis"
            }
    

    step 2: import the version of jar we wanted:

    api "org.springframework.data:spring-data-redis:2.5.0"
            api "redis.clients:jedis:3.6.0"
    

    step 3: force using the new version of jar:

     resolutionStrategy {
                eachDependency { DependencyResolveDetails details ->
                    if (details.requested.group == 'org.springframework.data' && details.requested.name == 'spring-data-redis' ) {
                        
                        details.useVersion("2.5.0")
                    }
                }
            }
    

  2. You’re using spring-data-redis 2.3.9.

    The support of Streams with Jedis is only available from 2.5.0. So you’ll have to use at least 2.5.0 version of spring-data-redis.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search