Interface RStream<K,V>
- Type Parameters:
K- key typeV- value type
- All Superinterfaces:
RExpirable,RExpirableAsync,RObject,RObjectAsync,RStreamAsync<K,V>
- All Known Implementing Classes:
RedissonStream
Requires Redis 5.0.0 and higher.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionlongack(String groupName, StreamMessageId... ids) Marks pending messages by group name and streamidsas correctly processed.add(StreamAddArgs<K, V> args) Appends a new entry/entries and returns generated Stream Message IDvoidadd(StreamMessageId id, StreamAddArgs<K, V> args) Appends a new entry/entries by specified Stream Message IDintaddListener(ObjectListener listener) Adds object event listenerautoClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId startId, int count) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages and startId are greater than defined value.Map<StreamMessageId, Map<K, V>> claim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId... ids) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages is greater than defined value.voidcreateConsumer(String groupName, String consumerName) Creates consumer of the group by name.voidCreates consumer group.fastAutoClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId startId, int count) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages and startId are greater than defined value.fastClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId... ids) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages is greater than defined value.StreamInfo<K, V> getInfo()Returns information about this stream.getPendingInfo(String groupName) Returns common info about pending messages by group name.listConsumers(String groupName) Returns list of common info about group customers for specifiedgroupName.Returns list of common info about groups belonging to this stream.listPending(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, int count) Returns list of common info about pending messages by group and consumer name.listPending(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group and customer name.listPending(String groupName, StreamMessageId startId, StreamMessageId endId, int count) Returns list of common info about pending messages by group name.listPending(String groupName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group name.Map<StreamMessageId, Map<K, V>> pendingRange(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, int count) Returns stream data of pending messages by group and customer name.Map<StreamMessageId, Map<K, V>> pendingRange(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group and customer name.Map<StreamMessageId, Map<K, V>> pendingRange(String groupName, StreamMessageId startId, StreamMessageId endId, int count) Returns stream data of pending messages by group name.Map<StreamMessageId, Map<K, V>> pendingRange(String groupName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group name.Map<StreamMessageId, Map<K, V>> range(int count, StreamMessageId startId, StreamMessageId endId) Returns stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included).Map<StreamMessageId, Map<K, V>> range(StreamMessageId startId, StreamMessageId endId) Returns stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included).Map<StreamMessageId, Map<K, V>> rangeReversed(int count, StreamMessageId startId, StreamMessageId endId) Returns stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included).Map<StreamMessageId, Map<K, V>> rangeReversed(StreamMessageId startId, StreamMessageId endId) Returns stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included).read(StreamMultiReadArgs args) Read stream data from multiple streams including current.Map<StreamMessageId, Map<K, V>> read(StreamReadArgs args) Read stream data from current stream only.readGroup(String groupName, String consumerName, StreamMultiReadGroupArgs args) Read stream data from consumer group and multiple streams including current.Map<StreamMessageId, Map<K, V>> readGroup(String groupName, String consumerName, StreamReadGroupArgs args) Read stream data from consumer group and current stream only.longremove(StreamMessageId... ids) Removes messages by id.longremoveConsumer(String groupName, String consumerName) Removes consumer of the group by name.voidremoveGroup(String groupName) Removes group by name.longsize()Returns number of entries in streamlongtrim(StreamTrimArgs args) Trims stream using strict trimming.longtrimNonStrict(StreamTrimArgs args) Trims stream using non-strict trimming.voidupdateGroupMessageId(String groupName, StreamMessageId id) Updates next message id delivered to consumers.Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLiveMethods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsyncMethods inherited from interface org.redisson.api.RObject
copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlinkMethods inherited from interface org.redisson.api.RObjectAsync
copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsyncMethods inherited from interface org.redisson.api.RStreamAsync
ackAsync, addAsync, addAsync, addListenerAsync, autoClaimAsync, claimAsync, createConsumerAsync, createGroupAsync, fastAutoClaimAsync, fastClaimAsync, getInfoAsync, getPendingInfoAsync, listConsumersAsync, listGroupsAsync, listPendingAsync, listPendingAsync, listPendingAsync, listPendingAsync, pendingRangeAsync, pendingRangeAsync, pendingRangeAsync, pendingRangeAsync, rangeAsync, rangeAsync, rangeReversedAsync, rangeReversedAsync, readAsync, readAsync, readGroupAsync, readGroupAsync, removeAsync, removeConsumerAsync, removeGroupAsync, sizeAsync, trimAsync, trimNonStrictAsync, updateGroupMessageIdAsync
-
Method Details
-
createGroup
Creates consumer group.Usage examples:
StreamMessageId id = stream.createGroup(StreamCreateGroupArgs.name("test").id(id).makeStream());- Parameters:
args- method arguments object
-
removeGroup
Removes group by name.- Parameters:
groupName- - name of group
-
createConsumer
Creates consumer of the group by name.Requires Redis 6.2.0 and higher.
- Parameters:
groupName- - name of groupconsumerName- - name of consumer
-
removeConsumer
Removes consumer of the group by name.- Parameters:
groupName- - name of groupconsumerName- - name of consumer- Returns:
- number of pending messages owned by consumer
-
updateGroupMessageId
Updates next message id delivered to consumers.- Parameters:
groupName- - name of groupid- - Stream Message ID
-
ack
Marks pending messages by group name and streamidsas correctly processed.- Parameters:
groupName- - name of groupids- - Stream Message IDs- Returns:
- marked messages amount
-
getPendingInfo
Returns common info about pending messages by group name.- Parameters:
groupName- - name of group- Returns:
- result object
-
listPending
List<PendingEntry> listPending(String groupName, StreamMessageId startId, StreamMessageId endId, int count) Returns list of common info about pending messages by group name. Limited by start Stream Message ID and end Stream Message ID and count.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message ID- Parameters:
groupName- - name of groupstartId- - start Stream Message IDendId- - end Stream Message IDcount- - amount of messages- Returns:
- list
- See Also:
-
listPending
List<PendingEntry> listPending(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, int count) Returns list of common info about pending messages by group and consumer name. Limited by start Stream Message ID and end Stream Message ID and count.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message ID- Parameters:
groupName- - name of groupconsumerName- - name of consumerstartId- - start Stream Message IDendId- - end Stream Message IDcount- - amount of messages- Returns:
- list
- See Also:
-
listPending
List<PendingEntry> listPending(String groupName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group name. Limited by minimum idle time, messages count, start and end Stream Message IDs.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message IDRequires Redis 6.2.0 and higher.
- Parameters:
groupName- - name of groupstartId- - start Stream Message IDendId- - end Stream Message IDidleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitcount- - amount of messages- Returns:
- map
- See Also:
-
listPending
List<PendingEntry> listPending(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group and customer name. Limited by minimum idle time, messages count, start and end Stream Message IDs.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message IDRequires Redis 6.2.0 and higher.
- Parameters:
groupName- - name of groupconsumerName- - name of consumerstartId- - start Stream Message IDendId- - end Stream Message IDidleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitcount- - amount of messages- Returns:
- map
- See Also:
-
pendingRange
Map<StreamMessageId,Map<K, pendingRangeV>> (String groupName, StreamMessageId startId, StreamMessageId endId, int count) Returns stream data of pending messages by group name. Limited by start Stream Message ID and end Stream Message ID and count.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message ID- Parameters:
groupName- - name of groupstartId- - start Stream Message IDendId- - end Stream Message IDcount- - amount of messages- Returns:
- map
- See Also:
-
pendingRange
Map<StreamMessageId,Map<K, pendingRangeV>> (String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, int count) Returns stream data of pending messages by group and customer name. Limited by start Stream Message ID and end Stream Message ID and count.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message ID- Parameters:
groupName- - name of groupconsumerName- - name of consumerstartId- - start Stream Message IDendId- - end Stream Message IDcount- - amount of messages- Returns:
- map
- See Also:
-
pendingRange
Map<StreamMessageId,Map<K, pendingRangeV>> (String groupName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group name. Limited by minimum idle time, messages count, start and end Stream Message IDs.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message IDRequires Redis 6.2.0 and higher.
- Parameters:
groupName- - name of groupstartId- - start Stream Message IDendId- - end Stream Message IDidleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitcount- - amount of messages- Returns:
- map
- See Also:
-
pendingRange
Map<StreamMessageId,Map<K, pendingRangeV>> (String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, long idleTime, TimeUnit idleTimeUnit, int count) Returns stream data of pending messages by group and customer name. Limited by minimum idle time, messages count, start and end Stream Message IDs.StreamMessageId.MAXis used as max Stream Message IDStreamMessageId.MINis used as min Stream Message IDRequires Redis 6.2.0 and higher.
- Parameters:
groupName- - name of groupconsumerName- - name of consumerstartId- - start Stream Message IDendId- - end Stream Message IDidleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitcount- - amount of messages- Returns:
- map
- See Also:
-
autoClaim
AutoClaimResult<K,V> autoClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId startId, int count) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages and startId are greater than defined value.- Parameters:
groupName- - name of groupconsumerName- - name of consumeridleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitstartId- - start Stream Message ID- Returns:
- stream data mapped by Stream ID
-
claim
Map<StreamMessageId,Map<K, claimV>> (String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId... ids) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages is greater than defined value.- Parameters:
groupName- - name of groupconsumerName- - name of consumeridleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitids- - Stream Message IDs- Returns:
- stream data mapped by Stream Message ID
-
fastClaim
List<StreamMessageId> fastClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId... ids) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages is greater than defined value.- Parameters:
groupName- - name of groupconsumerName- - name of consumeridleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitids- - Stream Message IDs- Returns:
- list of Stream Message IDs
-
fastAutoClaim
FastAutoClaimResult fastAutoClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId startId, int count) Transfers ownership of pending messages by id to a new consumer by name if idle time of messages and startId are greater than defined value.- Parameters:
groupName- - name of groupconsumerName- - name of consumeridleTime- - minimum idle time of messagesidleTimeUnit- - idle time unitstartId- - start Stream Message ID- Returns:
- list of Stream Message IDs
-
readGroup
Map<String,Map<StreamMessageId, readGroupMap<K, V>>> (String groupName, String consumerName, StreamMultiReadGroupArgs args) Read stream data from consumer group and multiple streams including current.Usage examples:
Map result = stream.read("group1", "consumer1", StreamMultiReadGroupArgs.greaterThan(id, "stream2", id2));Map result = stream.read("group1", "consumer1", StreamMultiReadGroupArgs.greaterThan(id, "stream2", id2) .count(100) .timeout(Duration.ofSeconds(5))));- Parameters:
args- - method arguments object- Returns:
- stream data mapped by stream name and Stream Message ID
-
readGroup
Map<StreamMessageId,Map<K, readGroupV>> (String groupName, String consumerName, StreamReadGroupArgs args) Read stream data from consumer group and current stream only.Usage examples:
Map result = stream.read("group1", "consumer1", StreamReadGroupArgs.greaterThan(id));Map result = stream.read("group1", "consumer1", StreamReadGroupArgs.greaterThan(id) .count(100) .timeout(Duration.ofSeconds(5))));- Parameters:
args- - method arguments object- Returns:
- stream data mapped by Stream Message ID
-
size
long size()Returns number of entries in stream- Returns:
- size of stream
-
add
Appends a new entry/entries and returns generated Stream Message IDUsage examples:
StreamMessageId id = stream.add(StreamAddArgs.entry(15, 37));
StreamMessageId id = stream.add(StreamAddArgs.entries(15, 37, 23, 43) .trim(TrimStrategy.MAXLEN, 100)));- Parameters:
args- - method arguments object- Returns:
- Stream Message ID
-
add
Appends a new entry/entries by specified Stream Message IDUsage examples:
stream.add(id, StreamAddArgs.entry(15, 37));
stream.add(id, StreamAddArgs.entries(15, 37, 23, 43) .trim(TrimStrategy.MAXLEN, 100)));- Parameters:
id- - Stream Message IDargs- - method arguments object
-
read
Read stream data from multiple streams including current.Usage examples:
Map result = stream.read(StreamMultiReadArgs.greaterThan(id, "stream2", id2));
Map result = stream.read(StreamMultiReadArgs.greaterThan(id, "stream2", id2) .count(100) .timeout(Duration.ofSeconds(5))));- Parameters:
args- - method arguments object- Returns:
- stream data mapped by stream name and Stream Message ID
-
read
Read stream data from current stream only.Usage examples:
Map result = stream.read(StreamReadArgs.greaterThan(id));
Map result = stream.read(StreamReadArgs.greaterThan(id) .count(100) .timeout(Duration.ofSeconds(5))));- Parameters:
args- - method arguments object- Returns:
- stream data mapped by Stream Message ID
-
range
Returns stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included).- Parameters:
startId- - start Stream Message IDendId- - end Stream Message ID- Returns:
- stream data mapped by Stream Message ID
-
range
Returns stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included).- Parameters:
count- - stream data size limitstartId- - start Stream Message IDendId- - end Stream Message ID- Returns:
- stream data mapped by Stream Message ID
-
rangeReversed
Returns stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included).- Parameters:
startId- - start Stream Message IDendId- - end Stream Message ID- Returns:
- stream data mapped by Stream Message ID
-
rangeReversed
Map<StreamMessageId,Map<K, rangeReversedV>> (int count, StreamMessageId startId, StreamMessageId endId) Returns stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included).- Parameters:
count- - stream data size limitstartId- - start Stream Message IDendId- - end Stream Message ID- Returns:
- stream data mapped by Stream Message ID
-
remove
Removes messages by id.- Parameters:
ids- - id of messages to remove- Returns:
- deleted messages amount
-
trim
Trims stream using strict trimming.Usage example:
long result = stream.trim(StreamTrimArgs.maxLen(100).noLimit());
- Parameters:
args- - method arguments object- Returns:
- number of deleted messages
-
trimNonStrict
Trims stream using non-strict trimming.Usage example:
long result = stream.trimNonStrict(StreamTrimArgs.maxLen(100).noLimit());
- Parameters:
args- - method arguments object- Returns:
- number of deleted messages
-
getInfo
StreamInfo<K,V> getInfo()Returns information about this stream.- Returns:
- info object
-
listGroups
List<StreamGroup> listGroups()Returns list of common info about groups belonging to this stream.- Returns:
- list of info objects
-
listConsumers
Returns list of common info about group customers for specifiedgroupName.- Parameters:
groupName- - name of group- Returns:
- list of info objects
-
addListener
Adds object event listener- Specified by:
addListenerin interfaceRObject- Parameters:
listener- - object event listener- Returns:
- listener id
- See Also:
-