Interface StreamOperations<K,HK,HV>
- All Superinterfaces:
HashMapperProvider<HK,HV>
Redis stream specific operations.
- Since:
- 2.2
- Author:
- Mark Paluch, Christoph Strobl, Dengliming, Marcin Zielinski, John Blum, jinkshower, Jeonggyu Choi
-
Method Summary
Modifier and TypeMethodDescriptiondefault Longacknowledge(@NonNull String group, @NonNull Record<@NonNull K, ?> record) Acknowledge the given record as processed.acknowledge(@NonNull K key, @NonNull String group, @NonNull String @NonNull ... recordIds) Acknowledge one or more records as processed.default Longacknowledge(@NonNull K key, @NonNull String group, @NonNull RecordId @NonNull ... recordIds) Acknowledge one or more records as processed.default RecordIdAppend a record to the streamkey.default RecordIdadd(@NonNull K key, @NonNull Map<? extends @NonNull HK, ? extends HV> content, @NonNull RedisStreamCommands.XAddOptions xAddOptions) Append a record to the streamkeywith the specified options.default RecordIdAppend a record, backed by aMapholding the field/value pairs, to the stream.default RecordIdadd(@NonNull MapRecord<K, ? extends HK, ? extends HV> record, @NonNull RedisStreamCommands.XAddOptions xAddOptions) Append a record, backed by aMapholding the field/value pairs, to the stream with the specified options.Append the record, backed by the given value, to the stream.add(@NonNull Record<K, ?> record, @NonNull RedisStreamCommands.XAddOptions xAddOptions) Append the record, backed by the given value, to the stream with the specified options.claim(@NonNull K key, @NonNull String consumerGroup, @NonNull String newOwner, @NonNull Duration minIdleTime, @NonNull RecordId @NonNull ... recordIds) Changes the ownership of a pending message so that the new owner is the consumer specified as the command argument.claim(@NonNull K key, @NonNull String consumerGroup, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions xClaimOptions) Changes the ownership of a pending message so that the new owner is the consumer specified as the command argument.Obtain information about every consumer in a specific consumer group for the stream stored at the specified key.default StringcreateGroup(@NonNull K key, @NonNull String group) Create a consumer group at thelatest offset.createGroup(@NonNull K key, @NonNull ReadOffset readOffset, @NonNull String group) Create a consumer group.default LongRemoves the specified records from the stream.Removes the specified records from the stream.default LongRemoves a givenRecordfrom the stream.deleteConsumer(@NonNull K key, @NonNull Consumer consumer) Delete a consumer from a consumer group.deserializeRecord(@NonNull ByteRecord record) Deserialize aByteRecordusing the configured serializers into aMapRecord.destroyGroup(@NonNull K key, @NonNull String group) Destroy a consumer group.<V> @NonNull HashMapper<V,HK, HV> getHashMapper(@NonNull Class<V> targetType) Get theHashMapperfor a specific type.Obtain information about consumer groups associated with the stream stored at the specified key.Obtain general information about the stream stored at the specified key.default <V> List<@NonNull ObjectRecord<K,V>> Map records fromMapRecordtoObjectRecords.default <V> ObjectRecord<K,V> Map record fromMapRecordtoObjectRecord.Obtain thePendingMessagesSummaryfor a given consumer group.pending(@NonNull K key, @NonNull String group, @NonNull Range<?> range, long count, @NonNull Duration minIdleTime) default PendingMessagesObtained detailed information about all pending messages for a givenConsumer.pending(@NonNull K key, @NonNull Consumer consumer, @NonNull Range<?> range, long count, @NonNull Duration minIdleTime) default <V> List<@NonNull ObjectRecord<K,V>> Read all records from a stream within a specificRangeasObjectRecord.default <V> List<@NonNull ObjectRecord<K,V>> range(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) Read records from a stream within a specificRange.default <V> List<ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group asObjectRecord.default <V> List<ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull Consumer consumer, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group asObjectRecord.default <V> List<@NonNull ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets asObjectRecord.default <V> List<@NonNull ObjectRecord<K,V>> read(@NonNull Class<V> targetType, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets asObjectRecord.read(@NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group.read(@NonNull Consumer consumer, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group.read(@NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets.read(StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets.default <V> List<@NonNull ObjectRecord<K,V>> reverseRange(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range) Read records from a stream within a specificRangein reverse order asObjectRecord.default <V> List<@NonNull ObjectRecord<K,V>> reverseRange(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) Read records from a stream within a specificRangeapplying aLimitin reverse order asObjectRecord.reverseRange(@NonNull K key, @NonNull Range<String> range) Read records from a stream within a specificRangein reverse order.reverseRange(@NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) Get the length of a stream.Trims the stream tocountelements.Trims the stream tocountelements.
-
Method Details
-
acknowledge
Acknowledge one or more records as processed.- Parameters:
key- the stream key.group- name of the consumer group.recordIds- record id's to acknowledge.- Returns:
- length of acknowledged records. null when used in pipeline / transaction.
- See Also:
-
acknowledge
default Long acknowledge(@NonNull K key, @NonNull String group, @NonNull RecordId @NonNull ... recordIds) Acknowledge one or more records as processed.- Parameters:
key- the stream key.group- name of the consumer group.recordIds- record id's to acknowledge.- Returns:
- length of acknowledged records. null when used in pipeline / transaction.
- See Also:
-
acknowledge
Acknowledge the given record as processed.- Parameters:
group- name of the consumer group.record- theRecordto acknowledge.- Returns:
- length of acknowledged records. null when used in pipeline / transaction.
- See Also:
-
add
default RecordId add(@NonNull K key, @NonNull Map<? extends @NonNull HK, ? extends HV> content, @NonNull RedisStreamCommands.XAddOptions xAddOptions) Append a record to the streamkeywith the specified options.- Parameters:
key- the stream key.content- record content as Map.xAddOptions- additional parameters for the XADD call.- Returns:
- the record Id. null when used in pipeline / transaction.
- Since:
- 3.4
- See Also:
-
add
default RecordId add(@NonNull MapRecord<K, ? extends HK, ? extends HV> record, @NonNull RedisStreamCommands.XAddOptions xAddOptions) Append a record, backed by aMapholding the field/value pairs, to the stream with the specified options.- Parameters:
record- the record to append.xAddOptions- additional parameters for the XADD call.- Returns:
- the record Id. null when used in pipeline / transaction.
- Since:
- 3.4
- See Also:
-
add
Append the record, backed by the given value, to the stream with the specified options. The value will be hashed and serialized.- Parameters:
record- must not be null.xAddOptions- parameters for the XADD call. Must not be null.- Returns:
- the record Id. null when used in pipeline / transaction.
- Since:
- 3.4
- See Also:
-
add
Append a record to the streamkey.- Parameters:
key- the stream key.content- record content as Map.- Returns:
- the record Id. null when used in pipeline / transaction.
- See Also:
-
add
Append a record, backed by aMapholding the field/value pairs, to the stream.- Parameters:
record- the record to append.- Returns:
- the record Id. null when used in pipeline / transaction.
- See Also:
-
add
Append the record, backed by the given value, to the stream. The value is mapped as hash and serialized.- Parameters:
record- must not be null.- Returns:
- the record Id. null when used in pipeline / transaction.
- See Also:
-
claim
default List<@NonNull MapRecord<K,HK, claimHV>> (@NonNull K key, @NonNull String consumerGroup, @NonNull String newOwner, @NonNull Duration minIdleTime, @NonNull RecordId @NonNull ... recordIds) Changes the ownership of a pending message so that the new owner is the consumer specified as the command argument. The message is claimed only if its idle time (ms) is greater than the givenminimum idle timespecified when calling XCLAIM.- Parameters:
key- {@link @NonNull K key} to the steam.consumerGroup-nameof the consumer group.newOwner-nameof the consumer claiming the message.minIdleTime-minimum idle timerequired for a message to be claimed.recordIds-record IDsto be claimed.- Returns:
Listof claimedMapRecords.- See Also:
-
claim
List<@NonNull MapRecord<K,HK, claimHV>> (@NonNull K key, @NonNull String consumerGroup, @NonNull String newOwner, @NonNull RedisStreamCommands.XClaimOptions xClaimOptions) Changes the ownership of a pending message so that the new owner is the consumer specified as the command argument. The message is claimed only if its idle time (ms) is greater than the givenminimum idle timespecified when calling XCLAIM.- Parameters:
key- {@link @NonNull K key} to the steam.consumerGroup-nameof the consumer group.newOwner-nameof the consumer claiming the message.xClaimOptions- additional parameters for the CLAIM call.- Returns:
Listof claimedMapRecords.- See Also:
-
delete
Removes the specified records from the stream. Returns the number of records deleted, that may be different from the number of IDs passed in case certain IDs do not exist.- Parameters:
key- the stream key.recordIds- stream record Id's.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- See Also:
-
delete
Removes a givenRecordfrom the stream.- Parameters:
record- must not be null.- Returns:
- he
Monoemitting the number of removed records.
-
delete
Removes the specified records from the stream. Returns the number of records deleted, that may be different from the number of IDs passed in case certain IDs do not exist.- Parameters:
key- the stream key.recordIds- stream record Id's.- Returns:
- the
Monoemitting the number of removed records. - See Also:
-
createGroup
Create a consumer group at thelatest offset. This command creates the stream if it does not already exist.- Parameters:
key- the key the stream is stored at.group- name of the consumer group.- Returns:
- OK if successful. null when used in pipeline / transaction.
-
createGroup
Create a consumer group. This command creates the stream if it does not already exist.- Parameters:
key- the key the stream is stored at.readOffset- theReadOffsetto apply.group- name of the consumer group.- Returns:
- OK if successful. null when used in pipeline / transaction.
-
deleteConsumer
Delete a consumer from a consumer group.- Parameters:
key- the stream key.consumer- consumer identified by group name and consumer key.- Returns:
- true if successful. null when used in pipeline / transaction.
-
destroyGroup
Destroy a consumer group.- Parameters:
key- the stream key.group- name of the consumer group.- Returns:
- true if successful. null when used in pipeline / transaction.
-
consumers
Obtain information about every consumer in a specific consumer group for the stream stored at the specified key.- Parameters:
key- the key the stream is stored at.group- name of the consumer group.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
groups
Obtain information about consumer groups associated with the stream stored at the specified key.- Parameters:
key- the key the stream is stored at.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
info
Obtain general information about the stream stored at the specified key.- Parameters:
key- the key the stream is stored at.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.3
-
pending
Obtain thePendingMessagesSummaryfor a given consumer group.- Parameters:
key- the key the stream is stored at. Must not be null.group- the name of the consumer group. Must not be null.- Returns:
- a summary of pending messages within the given consumer group or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
pending
Obtained detailed information about all pending messages for a givenConsumer.- Parameters:
key- the key the stream is stored at. Must not be null.consumer- the consumer to fetchPendingMessagesfor. Must not be null.- Returns:
- pending messages for the given
Consumeror null when used in pipeline / transaction. - Since:
- 2.3
- See Also:
-
pending
- Parameters:
key- the key the stream is stored at. Must not be null.group- the name of the consumer group. Must not be null.range- the range of messages ids to search within. Must not be null.count- limit the number of results.- Returns:
- pending messages for the given consumer group or null when used in pipeline / transaction.
- Since:
- 2.3
- See Also:
-
pending
PendingMessages pending(@NonNull K key, @NonNull String group, @NonNull Range<?> range, long count, @NonNull Duration minIdleTime) Obtain detailed information about pendingmessagesfor a givenRangewithin a consumer group and over a givenDurationof idle time.- Parameters:
key- the key the stream is stored at. Must not be null.group- the name of the consumer group. Must not be null.range- the range of messages ids to search within. Must not be null.count- limit the number of results. Must not be null.minIdleTime- the minimum idle time to filter pending messages. Must not be null.- Returns:
- pending messages for the given consumer group or null when used in pipeline / transaction.
- Since:
- 4.0
- See Also:
-
pending
PendingMessages pending(@NonNull K key, @NonNull Consumer consumer, @NonNull Range<?> range, long count) Obtain detailed information about pendingmessagesfor a givenRangeandConsumerwithin a consumer group.- Parameters:
key- the key the stream is stored at. Must not be null.consumer- the name of theConsumer. Must not be null.range- the range of messages ids to search within. Must not be null.count- limit the number of results.- Returns:
- pending messages for the given
Consumeror null when used in pipeline / transaction. - Since:
- 2.3
- See Also:
-
pending
PendingMessages pending(@NonNull K key, @NonNull Consumer consumer, @NonNull Range<?> range, long count, @NonNull Duration minIdleTime) Obtain detailed information about pendingmessagesfor a givenRangeandConsumerwithin a consumer group and over a givenDurationof idle time.- Parameters:
key- the key the stream is stored at. Must not be null.consumer- the name of theConsumer. Must not be null.range- the range of messages ids to search within. Must not be null.count- limit the number of results. Must not be null.minIdleTime- the minimum idle time to filter pending messages. Must not be null.- Returns:
- pending messages for the given
Consumeror null when used in pipeline / transaction. - Since:
- 3.5
- See Also:
-
size
Get the length of a stream.- Parameters:
key- the stream key.- Returns:
- length of the stream. null when used in pipeline / transaction.
- See Also:
-
range
Read records from a stream within a specificRange.- Parameters:
key- the stream key.range- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
range
- Parameters:
key- the stream key.range- must not be null.limit- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
range
default <V> List<@NonNull ObjectRecord<K,V>> range(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range) Read all records from a stream within a specificRangeasObjectRecord.- Parameters:
targetType- the target type of the payload.key- the stream key.range- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
range
default <V> List<@NonNull ObjectRecord<K,V>> range(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) - Parameters:
targetType- the target type of the payload.key- the stream key.range- must not be null.limit- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
Read records from one or moreStreamOffsets.- Parameters:
streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
default <V> List<@NonNull ObjectRecord<K,V>> read(@NonNull Class<V> targetType, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets asObjectRecord.- Parameters:
targetType- the target type of the payload.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
List<@NonNull MapRecord<K,HK, readHV>> (@NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets.- Parameters:
readOptions- read arguments.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
default <V> List<@NonNull ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets asObjectRecord.- Parameters:
targetType- the target type of the payload.readOptions- read arguments.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
default List<@NonNull MapRecord<K,HK, readHV>> (@NonNull Consumer consumer, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group.- Parameters:
consumer- consumer/group.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
default <V> List<ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull Consumer consumer, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group asObjectRecord.- Parameters:
targetType- the target type of the payload.consumer- consumer/group.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
List<@NonNull MapRecord<K,HK, readHV>> (@NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group.- Parameters:
consumer- consumer/group.readOptions- read arguments.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
read
default <V> List<ObjectRecord<K,V>> read(@NonNull Class<V> targetType, @NonNull Consumer consumer, @NonNull StreamReadOptions readOptions, StreamOffset<@NonNull K> @NonNull ... streams) Read records from one or moreStreamOffsets using a consumer group asObjectRecord.- Parameters:
targetType- the target type of the payload.consumer- consumer/group.readOptions- read arguments.streams- the streams to read from.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
reverseRange
default List<@NonNull MapRecord<K,HK, reverseRangeHV>> (@NonNull K key, @NonNull Range<String> range) Read records from a stream within a specificRangein reverse order.- Parameters:
key- the stream key.range- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
reverseRange
List<@NonNull MapRecord<K,HK, reverseRangeHV>> (@NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) - Parameters:
key- the stream key.range- must not be null.limit- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
reverseRange
default <V> List<@NonNull ObjectRecord<K,V>> reverseRange(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range) Read records from a stream within a specificRangein reverse order asObjectRecord.- Parameters:
targetType- the target type of the payload.key- the stream key.range- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
reverseRange
default <V> List<@NonNull ObjectRecord<K,V>> reverseRange(@NonNull Class<V> targetType, @NonNull K key, @NonNull Range<String> range, @NonNull Limit limit) Read records from a stream within a specificRangeapplying aLimitin reverse order asObjectRecord.- Parameters:
targetType- the target type of the payload.key- the stream key.range- must not be null.limit- must not be null.- Returns:
- list with members of the resulting stream. null when used in pipeline / transaction.
- See Also:
-
trim
Trims the stream tocountelements.- Parameters:
key- the stream key.count- length of the stream.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- See Also:
-
trim
Trims the stream tocountelements.- Parameters:
key- the stream key.count- length of the stream.approximateTrimming- the trimming must be performed in a approximated way in order to maximize performances.- Returns:
- number of removed entries. null when used in pipeline / transaction.
- Since:
- 2.4
- See Also:
-
getHashMapper
Get theHashMapperfor a specific type.- Specified by:
getHashMapperin interfaceHashMapperProvider<K,HK> - Type Parameters:
V-- Parameters:
targetType- must not be null.- Returns:
- the
HashMappersuitable for a given type;
-
map
Map record fromMapRecordtoObjectRecord.- Parameters:
record- the stream record to map.targetType- the target type of the payload.- Returns:
- the mapped
ObjectRecord. - Since:
- 2.x
-
map
default <V> List<@NonNull ObjectRecord<K,V>> map(@NonNull List<@NonNull MapRecord<K, HK, HV>> records, @NonNull Class<V> targetType) Map records fromMapRecordtoObjectRecords.- Parameters:
records- the stream records to map.targetType- the target type of the payload.- Returns:
- the mapped
object records. - Since:
- 2.x
-
deserializeRecord
Deserialize aByteRecordusing the configured serializers into aMapRecord.- Parameters:
record- the stream record to map.- Returns:
- deserialized
MapRecord. - Since:
- 2.x
-