Reads Redis stream data.

Parameters

NameTypeDefault valueDescription
batchSizeinteger1The number of new messages that will cause the functions to run
durationinteger0How many seconds to wait before execution, regardless of batch size
failurePolicyFailurePolicyFailurePolicy.CONTINUEHow to handle execution failure (CONTINUE/ABORT/RETRY)
failureRetryIntervalinteger5000The number of seconds to wait before retrying
patternstring“*” (match all keys)The pattern of keys that store streams
startIdstring“0-0”Start reading from this stream ID
trimStreambooleantrueWhether or not to trim the stream

Output records

Creates a record for each message in the input stream.

Each record is a HashMap<String, Object> with the following fields:

NameTypeDescription
idstringThe message’s ID
keystringThe stream key name
valueHashMap<String, byte[]>The message’s data

Examples

The following example creates a StreamReader with default values:

StreamReader reader = new StreamReader();

To change the parameter values for a StreamReader, use their setter methods:

StreamReader reader = new StreamReader();
// Get streams for keys that match "weather"
reader.setPattern("weather");
// Run RedisGears functions after every 10 messages
reader.setBatchSize(10);