6

I understand I can get the total length of a stream with xlen or xinfo stream mystream full.

I also understand that I can use xpending to get the length of the pending queue, items that have not been ack'd.

Is there a command to give me the count or identity of items that /have/ been ack'd? (Besides assuming that xlen - len(xpending) = len(unackd)?)

Mittenchops
  • 18,633
  • 33
  • 128
  • 246

1 Answers1

2

There's no built-in feature to count ack/processed messages in stream though you can accomplish this using LUA script and MULTI.

You can use the LUA script to count and ACK in the same flow.

ARGS: [my-group, message-id]
Keys: [{my-stream}, {my-stream}::my-group::counter ]

redis.call( 'XACK', KEYS[0], ARGS[0], ARGS[1] )
redis.call('INCR', KEYS[1] )

my-stream is the stream name and my-group is the consumer group name.

You can also use Multi/Exec

MULTI
XACK {my-stream} my-group message-id
INCR {my-stream}::my-group::counter
EXEC

I've tagged the counter and stream name to avoid cross slot errors in the Redis cluster. The counter is maintained for each consumer group and each stream.

sonus21
  • 5,178
  • 2
  • 23
  • 48