Reputation: 19664
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)
?)
Upvotes: 6
Views: 2693
Reputation: 5388
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.
Upvotes: 2