@Override public <HK, HV> ReactiveStreamOperations<K, HK, HV> opsForStream(HashMapper<? super K, ? super HK, ? super HV> hashMapper) { return opsForStream(serializationContext, hashMapper); }
@Override public <HK, HV> ReactiveStreamOperations<K, HK, HV> opsForStream() { return opsForStream(serializationContext); }
@SuppressWarnings("unchecked") public <HK, HV> ReactiveStreamOperations<K, HK, HV> opsForStream( RedisSerializationContext<K, ?> serializationContext) { return opsForStream(serializationContext, (HashMapper) new ObjectHashMapper()); }
/** * Create a new {@link DefaultStreamReceiver} given {@link ReactiveRedisConnectionFactory} and * {@link org.springframework.data.redis.stream.StreamReceiver.StreamReceiverOptions}. * * @param connectionFactory must not be {@literal null}. * @param options must not be {@literal null}. */ @SuppressWarnings("unchecked") DefaultStreamReceiver(ReactiveRedisConnectionFactory connectionFactory, StreamReceiverOptions<K, V> options) { receiverOptions = options; RedisSerializationContext<K, Object> serializationContext = RedisSerializationContext .<K, Object> newSerializationContext(options.getKeySerializer()) // .key(options.getKeySerializer()).hashKey(options.getHashKeySerializer()) .hashValue(options.getHashValueSerializer()).build(); StreamReadOptions readOptions = StreamReadOptions.empty(); if (options.getBatchSize().isPresent()) { readOptions = readOptions.count(options.getBatchSize().getAsInt()); } if (!options.getPollTimeout().isZero()) { readOptions = readOptions.block(options.getPollTimeout()); } this.readOptions = readOptions; this.template = new ReactiveRedisTemplate(connectionFactory, serializationContext); if (options.getHashMapper() != null) { this.streamOperations = this.template.opsForStream(options.getHashMapper()); } else { this.streamOperations = this.template.opsForStream(); } }