Stream
XREADGROUP
Reads data from a stream as part of a consumer group.
Arguments
groupbodystringrequired
The consumer group name.
consumerbodystringrequired
The consumer name within the group.
keybodystring | string[]required
The stream key(s) to read from. Can be a single stream key or an array of stream keys for multiple streams.
idsbodystring | string[]required
The starting ID(s) to read from. Use ">" to read messages never delivered to any consumer in the group. For multiple streams, provide an array of IDs corresponding to each stream.
optionsbody
Response
Array<[string, Array<[string, string[]]>]> | null
Returns an array where each element represents a stream and contains:
- The stream key
- An array of messages (ID and field-value pairs)
Returns null if no data is available.
Read new messages
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">");With count option
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">", { count: 5});With NOACK option
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">", { NOACK: true});Multiple streams
const result = await redis.xreadgroup( "mygroup", "consumer1", ["stream1", "stream2"], [">", ">"], { count: 1 });Read pending messages
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", "0");[ ["mystream", [ ["1638360173533-0", ["field1", "value1", "field2", "value2"]], ["1638360173533-1", ["field1", "value3", "field2", "value4"]] ]]]