Skip to content

Commit c0554f6

Browse files
authored
Update XINFO CONSUMERS reply (#3422)
with inactive field.
1 parent 9803f89 commit c0554f6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ public class StreamConsumersInfo {
1313
public static final String NAME = "name";
1414
public static final String IDLE = "idle";
1515
public static final String PENDING = "pending";
16+
public static final String INACTIVE = "inactive";
1617

1718
private final String name;
1819
private final long idle;
1920
private final long pending;
21+
private final Long inactive;
2022
private final Map<String, Object> consumerInfo;
2123

2224
/**
@@ -26,9 +28,9 @@ public StreamConsumersInfo(Map<String, Object> map) {
2628

2729
consumerInfo = map;
2830
name = (String) map.get(NAME);
29-
idle = (long) map.get(IDLE);
30-
pending = (long) map.get(PENDING);
31-
31+
idle = (Long) map.get(IDLE);
32+
pending = (Long) map.get(PENDING);
33+
inactive = (Long) map.get(INACTIVE);
3234
}
3335

3436
public String getName() {
@@ -44,6 +46,14 @@ public long getPending() {
4446
}
4547

4648
/**
49+
* Since Redis 7.2.
50+
*/
51+
public Long getInactive() {
52+
return inactive;
53+
}
54+
55+
/**
56+
* All data.
4757
* @return Generic map containing all key-value pairs returned by the server
4858
*/
4959
public Map<String, Object> getConsumerInfo() {

src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@ public void xinfo() throws InterruptedException {
848848
// Using getters
849849
assertEquals(MY_CONSUMER, consumersInfo.get(0).getName());
850850
assertEquals(0L, consumersInfo.get(0).getPending());
851-
assertTrue(consumersInfo.get(0).getIdle() > 0);
851+
MatcherAssert.assertThat(consumersInfo.get(0).getIdle(), Matchers.greaterThanOrEqualTo(0L));
852+
MatcherAssert.assertThat(consumersInfo.get(0).getInactive(), Matchers.any(Long.class));
852853

853854
// test with more groups and consumers
854855
jedis.xgroupCreate(STREAM_NAME, G2, StreamEntryID.LAST_ENTRY, false);

0 commit comments

Comments
 (0)