Class StreamReceiver.StreamReceiverOptionsBuilder<K,V extends Record<K,?>>
java.lang.Object
org.springframework.data.redis.stream.StreamReceiver.StreamReceiverOptionsBuilder<K,V>
- Type Parameters:
K
- Stream key and Stream field type.
- Enclosing interface:
- StreamReceiver<K,
V extends Record<K, ?>>
public static class StreamReceiver.StreamReceiverOptionsBuilder<K,V extends Record<K,?>>
extends Object
Builder for
StreamReceiver.StreamReceiverOptions
.-
Method Summary
Modifier and TypeMethodDescriptionbatchSize
(int recordsPerPoll) Configure a batch size for theCOUNT
option during reading.build()
Build newStreamReceiver.StreamReceiverOptions
.<HK,
HV> StreamReceiver.StreamReceiverOptionsBuilder<K, MapRecord<K, HK, HV>> Configure a hash key serializer.<HK,
HV> StreamReceiver.StreamReceiverOptionsBuilder<K, MapRecord<K, HK, HV>> Configure a hash value serializer.<NK,
NV extends Record<NK, ?>>
StreamReceiver.StreamReceiverOptionsBuilder<NK,NV> Configure a key serializer.objectMapper
(HashMapper<NV, ?, ?> hashMapper) Configure a hash mapper.onErrorResume
(Function<? super Throwable, ? extends org.reactivestreams.Publisher<Void>> resumeFunction) Configure a resumeFunction
to resume the main sequence when polling the stream fails.pollTimeout
(Duration pollTimeout) Configure a poll timeout for theBLOCK
option during reading.<T> StreamReceiver.StreamReceiverOptionsBuilder<T,
MapRecord<T, T, T>> Configure a key, hash key and hash value serializer.<T> StreamReceiver.StreamReceiverOptionsBuilder<T,
MapRecord<T, T, T>> serializer
(RedisSerializationContext<T, ?> serializationContext) Configure a key, hash key and hash value serializer.targetType
(Class<NV> targetType) Configure a hash target type.
-
Method Details
-
pollTimeout
Configure a poll timeout for theBLOCK
option during reading.- Parameters:
pollTimeout
- must not be null or negative.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
batchSize
Configure a batch size for theCOUNT
option during reading.- Parameters:
recordsPerPoll
- must be greater zero.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
onErrorResume
public StreamReceiver.StreamReceiverOptionsBuilder<K,V> onErrorResume(Function<? super Throwable, ? extends org.reactivestreams.Publisher<Void>> resumeFunction) Configure a resumeFunction
to resume the main sequence when polling the stream fails. The function can either resume by suppressing the error or fail the main sequence by emitting the error to stop receiving. Receive errors (Redis errors, Serialization failures) stop receiving by default.- Parameters:
resumeFunction
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.- Since:
- 2.x
- See Also:
-
Flux.onErrorResume(Function)
-
serializer
public <T> StreamReceiver.StreamReceiverOptionsBuilder<T,MapRecord<T, serializerT, T>> (RedisSerializationContext.SerializationPair<T> pair) Configure a key, hash key and hash value serializer.- Parameters:
pair
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
serializer
public <T> StreamReceiver.StreamReceiverOptionsBuilder<T,MapRecord<T, serializerT, T>> (RedisSerializationContext<T, ?> serializationContext) Configure a key, hash key and hash value serializer.- Parameters:
serializationContext
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
keySerializer
public <NK,NV extends Record<NK, StreamReceiver.StreamReceiverOptionsBuilder<NK,?>> NV> keySerializer(RedisSerializationContext.SerializationPair<NK> pair) Configure a key serializer.- Parameters:
pair
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
hashKeySerializer
public <HK,HV> StreamReceiver.StreamReceiverOptionsBuilder<K,MapRecord<K, hashKeySerializerHK, HV>> (RedisSerializationContext.SerializationPair<HK> pair) Configure a hash key serializer.- Parameters:
pair
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
hashValueSerializer
public <HK,HV> StreamReceiver.StreamReceiverOptionsBuilder<K,MapRecord<K, hashValueSerializerHK, HV>> (RedisSerializationContext.SerializationPair<HV> pair) Configure a hash value serializer.- Parameters:
pair
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
targetType
public <NV> StreamReceiver.StreamReceiverOptionsBuilder<K,ObjectRecord<K, targetTypeNV>> (Class<NV> targetType) Configure a hash target type. Changes the emittedRecord
type toObjectRecord
.- Parameters:
targetType
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
objectMapper
public <NV> StreamReceiver.StreamReceiverOptionsBuilder<K,ObjectRecord<K, objectMapperNV>> (HashMapper<NV, ?, ?> hashMapper) Configure a hash mapper. Changes the emittedRecord
type toObjectRecord
.- Parameters:
hashMapper
- must not be null.- Returns:
this
StreamReceiver.StreamReceiverOptionsBuilder
.
-
build
Build newStreamReceiver.StreamReceiverOptions
.- Returns:
- new
StreamReceiver.StreamReceiverOptions
.
-