Use XREADGROUP to get the id specified

1.2k Views Asked by At

I'm wondering if there is a command or parameter with which I can get the message for the RecordId specified e.g.

XREADGROUP GROUP mygroup myconsumer COUNT 1 STREAMS mystream 12345-0

I want the message with the ID 12345-0, but it seems I get the first message after 12345-0.

I cannot use XRANGE since it doesn't update the deliveryCount and lastDeliveryTime and it doesn't seem to understand the concept of consumer groups.

I'm also aware of

XREADGROUP GROUP mygroup myconsumer STREAMS mystream 0

which gives me all pending messages, but this would update the deliveryCount for all messages and I don't want that.

1

There are 1 best solutions below

1
On BEST ANSWER

Redis itself doesn't provide the function you ask for. So instead you might have to use something like

XREADGROUP GROUP mygroup myconsumer COUNT 1 STREAMS mystream 12344-99999

instead of "12345-0"

The entry id returned by Redis Stream is in the format of millisecondsTime-sequenceNumber. Since it's unlikely you insert 99999 items in one milisecond, you can be sure that you get the correct item.