All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.redisson.api.RStream Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
/**
 * Copyright 2018 Nikita Koksharov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.redisson.api;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Interface for Redis Stream object.
 * 

* Requires Redis 5.0.0 and higher. * * @author Nikita Koksharov * * @param key type * @param value type */ public interface RStream extends RStreamAsync, RExpirable { /** * Creates consumer group by name. * * @param groupName - name of group */ void createGroup(String groupName); /** * Creates consumer group by name and Stream Message ID. * Only new messages after defined stream id will be available for consumers of this group. *

* {@link StreamMessageId#NEWEST} is used for messages arrived since the moment of group creating * * @param groupName - name of group * @param id - Stream Message ID */ void createGroup(String groupName, StreamMessageId id); /** * Removes group by name. * * @param groupName - name of group */ void removeGroup(String groupName); /** * Removes consumer of the group by name. * * @param groupName - name of group * @param consumerName - name of consumer * @return number of pending messages owned by consumer */ long removeConsumer(String groupName, String consumerName); /** * Updates next message id delivered to consumers. * * @param groupName - name of group * @param id - Stream Message ID */ void updateGroupMessageId(String groupName, StreamMessageId id); /** * Marks pending messages by group name and stream ids as correctly processed. * * @param groupName - name of group * @param ids - Stream Message IDs * @return marked messages amount */ long ack(String groupName, StreamMessageId... ids); /** * Returns pending messages by group name * * @param groupName - name of group * @return result object */ PendingResult listPending(String groupName); /** * Returns list of pending messages by group name. * Limited by start Stream Message ID and end Stream Message ID and count. *

* {@link StreamMessageId#MAX} is used as max Stream Message ID * {@link StreamMessageId#MIN} is used as min Stream Message ID * * @param groupName - name of group * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @param count - amount of messages * @return list */ List listPending(String groupName, StreamMessageId startId, StreamMessageId endId, int count); /** * Returns list of pending messages by group name and consumer name. * Limited by start Stream Message ID and end Stream Message ID and count. *

* {@link StreamMessageId#MAX} is used as max Stream Message ID * {@link StreamMessageId#MIN} is used as min Stream Message ID * * @param consumerName - name of consumer * @param groupName - name of group * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @param count - amount of messages * @return list */ List listPending(String groupName, String consumerName, StreamMessageId startId, StreamMessageId endId, int count); /** * Transfers ownership of pending messages by id to a new consumer * by name if idle time of messages is greater than defined value. * * @param groupName - name of group * @param consumerName - name of consumer * @param idleTime - minimum idle time of messages * @param idleTimeUnit - idle time unit * @param ids - Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> 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. * * @param groupName - name of group * @param consumerName - name of consumer * @param idleTime - minimum idle time of messages * @param idleTimeUnit - idle time unit * @param ids - Stream Message IDs * @return list of Stream Message IDs */ List fastClaim(String groupName, String consumerName, long idleTime, TimeUnit idleTimeUnit, StreamMessageId ... ids); /** * Read stream data from groupName by consumerName and specified collection of Stream Message IDs. * * @param groupName - name of group * @param consumerName - name of consumer * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> readGroup(String groupName, String consumerName, StreamMessageId ... ids); /** * Read stream data from groupName by consumerName and specified collection of Stream Message IDs. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> readGroup(String groupName, String consumerName, int count, StreamMessageId ... ids); /** * Read stream data from groupName by consumerName and specified collection of Stream Message IDs. * Waits for stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> readGroup(String groupName, String consumerName, long timeout, TimeUnit unit, StreamMessageId ... ids); /** * Read stream data from groupName by consumerName and specified collection of Stream Message IDs. * Waits for stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> readGroup(String groupName, String consumerName, int count, long timeout, TimeUnit unit, StreamMessageId ... ids); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param id - starting message id for this stream * @param nameToId - Stream Message ID mapped by stream name * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, StreamMessageId id, Map nameToId); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param id - starting message id for this stream * @param nameToId - Stream Message ID mapped by stream name * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, StreamMessageId id, Map nameToId); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param nameToId - Stream Message ID mapped by stream name * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, long timeout, TimeUnit unit, StreamMessageId id, Map nameToId); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param nameToId - Stream Message ID mapped by stream name * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, long timeout, TimeUnit unit, StreamMessageId id, Map nameToId); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, StreamMessageId id, String key2, StreamMessageId id2); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @param key3 - name of third stream * @param id3 - starting message id for third stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, StreamMessageId id, String key2, StreamMessageId id2, String key3, StreamMessageId id3); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, StreamMessageId id, String key2, StreamMessageId id2); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @param key3 - name of third stream * @param id3 - starting message id for third stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, StreamMessageId id, String key2, StreamMessageId id2, String key3, StreamMessageId id3); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, long timeout, TimeUnit unit, StreamMessageId id, String key2, StreamMessageId id2); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @param key3 - name of third stream * @param id3 - starting message id for third stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, long timeout, TimeUnit unit, StreamMessageId id, String key2, StreamMessageId id2, String key3, StreamMessageId id3); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, long timeout, TimeUnit unit, StreamMessageId id, String key2, StreamMessageId id2); /** * Read stream data from groupName by consumerName, starting by specified message ids for this and other streams. * Waits for the first stream data availability for specified timeout interval. * * @param groupName - name of group * @param consumerName - name of consumer * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - starting message id for this stream * @param key2 - name of second stream * @param id2 - starting message id for second stream * @param key3 - name of third stream * @param id3 - starting message id for third stream * @return stream data mapped by key and Stream Message ID */ Map>> readGroup(String groupName, String consumerName, int count, long timeout, TimeUnit unit, StreamMessageId id, String key2, StreamMessageId id2, String key3, StreamMessageId id3); /** * Returns number of entries in stream * * @return size of stream */ long size(); /** * Appends a new entry and returns generated Stream Message ID * * @param key - key of entry * @param value - value of entry * @return Stream Message ID */ StreamMessageId add(K key, V value); /** * Appends a new entry by specified Stream Message ID * * @param id - Stream Message ID * @param key - key of entry * @param value - value of entry */ void add(StreamMessageId id, K key, V value); /** * Appends a new entry and returns generated Stream Message ID. * Trims stream to a specified trimLen size. * If trimStrict is false then trims to few tens of entries more than specified length to trim. * * @param key - key of entry * @param value - value of entry * @param trimLen - length to trim * @param trimStrict - if false then trims to few tens of entries more than specified length to trim * @return Stream Message ID */ StreamMessageId add(K key, V value, int trimLen, boolean trimStrict); /** * Appends a new entry by specified Stream Message ID. * Trims stream to a specified trimLen size. * If trimStrict is false then trims to few tens of entries more than specified length to trim. * * @param id - Stream Message ID * @param key - key of entry * @param value - value of entry * @param trimLen - length to trim * @param trimStrict - if false then trims to few tens of entries more than specified length to trim */ void add(StreamMessageId id, K key, V value, int trimLen, boolean trimStrict); /** * Appends new entries and returns generated Stream Message ID * * @param entries - entries to add * @return Stream Message ID */ StreamMessageId addAll(Map entries); /** * Appends new entries by specified Stream Message ID * * @param id - Stream Message ID * @param entries - entries to add */ void addAll(StreamMessageId id, Map entries); /** * Appends new entries and returns generated Stream Message ID. * Trims stream to a specified trimLen size. * If trimStrict is false then trims to few tens of entries more than specified length to trim. * * @param entries - entries to add * @param trimLen - length to trim * @param trimStrict - if false then trims to few tens of entries more than specified length to trim * @return Stream Message ID */ StreamMessageId addAll(Map entries, int trimLen, boolean trimStrict); /** * Appends new entries by specified Stream Message ID. * Trims stream to a specified trimLen size. * If trimStrict is false then trims to few tens of entries more than specified length to trim. * * @param id - Stream Message ID * @param entries - entries to add * @param trimLen - length to trim * @param trimStrict - if false then trims to few tens of entries more than specified length to trim */ void addAll(StreamMessageId id, Map entries, int trimLen, boolean trimStrict); /** * Read stream data by specified collection of Stream Message IDs. * * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> read(StreamMessageId ... ids); /** * Read stream data by specified collection of Stream Message IDs. * * @param count - stream data size limit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> read(int count, StreamMessageId ... ids); /** * Read stream data by specified collection of Stream Message IDs. * Wait for stream data availability for specified timeout interval. * * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> read(long timeout, TimeUnit unit, StreamMessageId ... ids); /** * Read stream data by specified collection of Stream Message IDs. * Wait for stream data availability for specified timeout interval. * * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param ids - collection of Stream Message IDs * @return stream data mapped by Stream Message ID */ Map> read(int count, long timeout, TimeUnit unit, StreamMessageId ... ids); /** * Read stream data by specified stream name including this stream. * * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @return stream data mapped by key and Stream Message ID */ Map>> read(StreamMessageId id, String name2, StreamMessageId id2); /** * Read stream data by specified stream names including this stream. * * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @param name3 - name of third stream * @param id3 - id of third stream * @return stream data mapped by key and Stream Message ID */ Map>> read(StreamMessageId id, String name2, StreamMessageId id2, String name3, StreamMessageId id3); /** * Read stream data by specified Stream Message ID mapped by name including this stream. * * @param id - id of this stream * @param nameToId - Stream Message ID mapped by name * @return stream data mapped by key and Stream Message ID */ Map>> read(StreamMessageId id, Map nameToId); /** * Read stream data by specified stream name including this stream. * * @param count - stream data size limit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, StreamMessageId id, String name2, StreamMessageId id2); /** * Read stream data by specified stream names including this stream. * * @param count - stream data size limit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @param name3 - name of third stream * @param id3 - id of third stream * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, StreamMessageId id, String name2, StreamMessageId id2, String name3, StreamMessageId id3); /** * Read stream data by specified Stream Message ID mapped by name including this stream. * * @param count - stream data size limit * @param id - id of this stream * @param nameToId - Stream Message ID mapped by name * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, StreamMessageId id, Map nameToId); /** * Read stream data by specified stream name including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @return stream data mapped by key and Stream Message ID */ Map>> read(long timeout, TimeUnit unit, StreamMessageId id, String name2, StreamMessageId id2); /** * Read stream data by specified stream names including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @param name3 - name of third stream * @param id3 - id of third stream * @return stream data mapped by key and Stream Message ID */ Map>> read(long timeout, TimeUnit unit, StreamMessageId id, String name2, StreamMessageId id2, String name3, StreamMessageId id3); /** * Read stream data by specified Stream Message ID mapped by name including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param nameToId - Stream Message ID mapped by name * @return stream data mapped by key and Stream Message ID */ Map>> read(long timeout, TimeUnit unit, StreamMessageId id, Map nameToId); /** * Read stream data by specified stream name including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, long timeout, TimeUnit unit, StreamMessageId id, String name2, StreamMessageId id2); /** * Read stream data by specified stream names including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param name2 - name of second stream * @param id2 - id of second stream * @param name3 - name of third stream * @param id3 - id of third stream * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, long timeout, TimeUnit unit, StreamMessageId id, String name2, StreamMessageId id2, String name3, StreamMessageId id3); /** * Read stream data by specified Stream Message ID mapped by name including this stream. * Wait for the first stream data availability for specified timeout interval. * * @param count - stream data size limit * @param timeout - time interval to wait for stream data availability * @param unit - time interval unit * @param id - id of this stream * @param nameToId - Stream Message ID mapped by name * @return stream data mapped by key and Stream Message ID */ Map>> read(int count, long timeout, TimeUnit unit, StreamMessageId id, Map nameToId); /** * Read stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included). * * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @return stream data mapped by Stream Message ID */ Map> range(StreamMessageId startId, StreamMessageId endId); /** * Read stream data in range by specified start Stream Message ID (included) and end Stream Message ID (included). * * @param count - stream data size limit * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @return stream data mapped by Stream Message ID */ Map> range(int count, StreamMessageId startId, StreamMessageId endId); /** * Read stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included). * * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @return stream data mapped by Stream Message ID */ Map> rangeReversed(StreamMessageId startId, StreamMessageId endId); /** * Read stream data in reverse order in range by specified start Stream Message ID (included) and end Stream Message ID (included). * * @param count - stream data size limit * @param startId - start Stream Message ID * @param endId - end Stream Message ID * @return stream data mapped by Stream Message ID */ Map> rangeReversed(int count, StreamMessageId startId, StreamMessageId endId); /** * Removes messages by id. * * @param ids - id of messages to remove * @return deleted messages amount */ long remove(StreamMessageId... ids); /** * Trims stream to specified size * * @param size - new size of stream * @return number of deleted messages */ long trim(int size); /** * Trims stream to few tens of entries more than specified length to trim. * * @param size - new size of stream * @return number of deleted messages */ long trimNonStrict(int size); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy