Skip to content
Advertisement

Jedis does not support returning PendingMessagesSummary

When I start the spring app write with Java 11, show error like this:

[12:36:01:729] [ERROR] - com.dolphin.soa.post.common.mq.PendingMessageConsume.pendingMessage(PendingMessageConsume.java:36) - handle pending message with an error
java.lang.UnsupportedOperationException: Jedis does not support returning PendingMessagesSummary.
    at org.springframework.data.redis.connection.jedis.JedisStreamCommands.xPending(JedisStreamCommands.java:279) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.connection.DefaultedRedisConnection.xPending(DefaultedRedisConnection.java:567) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.connection.DefaultStringRedisConnection.xPending(DefaultStringRedisConnection.java:4758) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.core.DefaultStreamOperations.lambda$pending$11(DefaultStreamOperations.java:250) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.core.DefaultStreamOperations$$Lambda$1468/0x00000000640b3c40.doInRedis(Unknown Source) ~[?:?]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:223) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:97) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at org.springframework.data.redis.core.DefaultStreamOperations.pending(DefaultStreamOperations.java:250) ~[spring-data-redis-2.6.4.jar!/:2.6.4]
    at com.dolphin.soa.post.common.mq.PendingMessageConsume.handlePendingMessage(PendingMessageConsume.java:42) ~[classes!/:?]
    at com.dolphin.soa.post.common.mq.PendingMessageConsume.pendingMessage(PendingMessageConsume.java:34) [classes!/:?]
    at jdk.internal.reflect.GeneratedMethodAccessor210.invoke(Unknown Source) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]

I have already upgrade the Jedis version to the newest 4.2.3, why still did not support the Redis pending command? I have already read the Jedis issue. They already added the pending support in the Jedis 3.6.0, why still tell me that did not support? This is the project Jedis dependencies look like:

➜  dolphin-post git:(master) ✗ ./gradlew :dolphin-post:dolphin-post-service:dependencies --configuration runtimeClasspath|grep -v "(*)"|grep -C 10 "jedis"
     |    |    |    --- org.springframework:spring-webmvc:5.3.19
     |    |    +--- org.springframework.boot:spring-boot-starter-data-redis -> 2.6.7
     |    |    |    --- org.springframework.data:spring-data-redis:2.6.4
     |    |    |         +--- org.springframework.data:spring-data-keyvalue:2.6.4
     |    |    |         |    +--- org.springframework.data:spring-data-commons:2.6.4
     |    |    |         |    |    --- org.slf4j:slf4j-api:1.7.32 -> 1.7.36
     |    |    |         |    +--- org.springframework:spring-tx:5.3.19
     |    |    |         |    --- org.slf4j:slf4j-api:1.7.32 -> 1.7.36
     |    |    |         +--- org.springframework:spring-oxm:5.3.19
     |    |    |         --- org.slf4j:slf4j-api:1.7.32 -> 1.7.36
     |    |    +--- redis.clients:jedis:4.2.3 -> 3.7.1
     |    |    |    +--- org.slf4j:slf4j-api:1.7.30 -> 1.7.36
     |    |    |    --- org.apache.commons:commons-pool2:2.10.0 -> 2.11.1
     |    |    +--- org.springframework.session:spring-session-data-redis -> 2.6.3
     |    |    |    +--- org.springframework.session:spring-session-core:2.6.3
     |    |    |    |    --- org.springframework:spring-jcl:5.3.19
     |    |    +--- org.springframework.boot:spring-boot-starter-aop -> 2.6.7
     |    |    |    --- org.aspectj:aspectjweaver:1.9.7
     |    |    +--- org.springframework.boot:spring-boot-starter-test -> 2.6.7
     |    |    |    +--- org.springframework.boot:spring-boot-test:2.6.7
     |    |    |    +--- org.springframework.boot:spring-boot-test-autoconfigure:2.6.7

this is my java code looks like:

void handlePendingMessage(){
        StreamOperations<String, String, String> streamOperations = this.stringRedisTemplate.opsForStream();
       PendingMessagesSummary pendingMessagesSummary = streamOperations.pending(consumer,groupName);
       Long totalPendingMessageCount = pendingMessagesSummary.getTotalPendingMessages();
       String groupName = pendingMessagesSummary.getGroupName();
        List<MapRecord<String, String, String>> retVal = streamOperations.read(Consumer.from(groupName, "my_consumer1"), StreamOffset.create(consumer, ReadOffset.from("0")));
        for (MapRecord<String, String, String> record : retVal ) {
            //streamOperations.acknowledge(groupName, record);
        }
    }

what should I do to make it support PendingMessagesSummary?

Advertisement

Answer

You are not using Jedis directly. You are using it through spring-data-redis.

Even though Jedis has added the support of PendingMessagesSummary, spring-data-redis has not included the support of Jedis. That is why you are getting the error.

5 People found this is helpful
Advertisement